ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
Vector and Matrix Operations

Functions

double det (const dmatrix &m1)
 Compute determinant of a constant matrix. More...
 
dvar_matrixdvar3_array::elem (int i)
 ? Retrieves an element of a dvar3_array. More...
 
prevariable dvar3_array::elem (int i, int j, int k)
 ? Retrieves an element of a dvar3_array. More...
 
const dvar_matrixdvar3_array::elem (int i) const
 ? Retrieves an element of a dvar3_array. More...
 
const prevariable dvar3_array::elem (int i, int j, int k) const
 ? Retrieves an element of a dvar3_array. More...
 
dvector elem_div (const dvector &t1, const dvector &t2)
 Element-wise division of two vectors; constant objects. More...
 
dvector elem_prod (const dvector &t1, const dvector &t2)
 Element-wise multiplication of two vectors; constant objects. More...
 
dmatrix expm (const dmatrix &A)
 Matrix exponential. More...
 
dvar_matrix expm (const dvar_matrix &A)
 Matrix exponential. More...
 
df1b2matrix expm (const df1b2matrix &A)
 Matrix exponential. More...
 
dmatrix inv (const dmatrix &m1)
 Inverse of a constant matrix by LU decomposition. More...
 
double norm (const dvector &t1)
 Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California. More...
 
double norm (const dmatrix &m1)
 Norm of a matrix; constant object. More...
 
double norm2 (const dvector &t1)
 Squared norm of a vector; constant objects. More...
 
double norm2 (const dmatrix &m1)
 Norm squared of a matrix; constant object. More...
 
int operator* (const ivector &t1, const ivector &t2)
 Compute the dot product of two vectors. More...
 
dvariable operator* (const dvar_vector &v1, const dvar_vector &v2)
 Compute the dot product of two variable type vectors. More...
 
double operator* (const dvector &t1, const dvector &t2)
 Compute the dot product of two vectors. More...
 
dvector operator* (const double x, const dvector &t1)
 Multiply a dvector by a constant. More...
 
dvector operator+ (const dvector &t1, const dvector &t2)
 Add two dvectors. More...
 
dvector operator- (const dvector &t1, const dvector &t2)
 Subtract two dvectors. More...
 
dvectordvector::operator= (const dvector &t)
 Assignment operator for dvector argument. More...
 
dvectordvector::operator= (double x)
 Assignment operator for double argument. More...
 
independent_variablesindependent_variables::operator= (const dvector &t)
 Assignment operator for dvector argument. More...
 
dvectordvector::shift (int min)
 Shift valid range of subscripts. More...
 
dvariable sum (const dvar_vector &v1)
 Compute the sum of a variable type vector. More...
 
dvariable sum (const dvar_matrix &m)
 Compute the sum of a variable type matrix. More...
 
double sumsq (const dmatrix &m1)
 Calls norm2. More...
 
dmatrix trans (const dmatrix &m1)
 Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California. More...
 

Detailed Description

The syntax of ADMB Matrix and vector operations follows normal mathematical conventions as much as possible. If u and v are vectors and M is a matrix,

u*M

is a normal matrix multiplication and

u*v

is a dot product. Element-wise multiplications and divisions are accomplished by elem_prod and elem_div respectively. If the arguments to these operations are not conformable for the appropriate type and operation, the application will exit with an error message.

These operations have been overloaded for appropriate combinations of constant and variable objects. The overloaded versions with variable types are optimized for efficient derivative computation. Only the constant types are currently documented here.

Function Documentation

double det ( const dmatrix m1)

Compute determinant of a constant matrix.

Parameters
m1A dmatrix, $M$, for which the determinant is computed.
Returns
A double containing $|M|$.

The implementation of this algorithm was inspired by "Numerical Recipes in C", 2nd edition, Press, Teukolsky, Vetterling, Flannery, chapter 2

Definition at line 499 of file dmat3.cpp.

Referenced by det().

dvar_matrix& dvar3_array::elem ( int  i)
inline

? Retrieves an element of a dvar3_array.

Parameters
iInteger specifying slice
Returns
dvariable containing the desired element

Definition at line 4315 of file fvar.hpp.

Referenced by dvar3_array::fill_randn(), dvar3_array::fill_randn_ni(), dvar3_array::fill_randu(), dvar3_array::fill_randu_ni(), and dvar3_array::operator=().

prevariable dvar3_array::elem ( int  i,
int  j,
int  k 
)
inline

? Retrieves an element of a dvar3_array.

Parameters
iInteger specifying slice
jInteger specifying row within slice
kinteger specifying column within row
Returns
dvariable containing the desired element

Definition at line 4324 of file fvar.hpp.

const dvar_matrix& dvar3_array::elem ( int  i) const
inline

? Retrieves an element of a dvar3_array.

Parameters
iInteger specifying slice
Returns
dvariable containing the desired element

Definition at line 4331 of file fvar.hpp.

const prevariable dvar3_array::elem ( int  i,
int  j,
int  k 
) const
inline

? Retrieves an element of a dvar3_array.

Parameters
iInteger specifying slice
jInteger specifying row within slice
kinteger specifying column within row
Returns
dvariable containing the desired element

Definition at line 4340 of file fvar.hpp.

dvector elem_div ( const dvector t1,
const dvector t2 
)

Element-wise division of two vectors; constant objects.

Exits with error if bounds of the two arguments differ.

Parameters
t1A vector, $u$ with valid subscripts in $[i_1,i_n]$
t2A vector, $v$ with valid subscripts in $[i_1,i_n]$
Returns
A vector containing $z_i = u_i\div v_i; [i_1,i_n]$.

Definition at line 58 of file dvect2.cpp.

dvector elem_prod ( const dvector t1,
const dvector t2 
)

Element-wise multiplication of two vectors; constant objects.

Exits with error if bounds of the two arguments differ.

Parameters
t1A vector, $u$ with valid subscripts in $[i_1,i_n]$
t2A vector, $v$ with valid subscripts in $[i_1,i_n]$
Returns
A vector containing $z_i = u_i\times v_i; [i_1,i_n]$.

Definition at line 20 of file dvect2.cpp.

dmatrix expm ( const dmatrix A)

Matrix exponential.

The matrix exponential is calculated using the Pade approximation adapted from Moler, Cleve; Van Loan, Charles F. (2003), "Nineteen Dubious Ways to Compute the Exponential of a Matrix, Twenty-Five Years Later"

The main use of the matrix exponential is to solve linear ordinary differential equation (ODE) systems:

\[ \frac{d}{dt}y(t) = Ay(t)\ , \ \mbox{with } y(0) = y_0 \]

then the solution becomes

\[ y(t) = e^{At}y_0 \]

Parameters
Asquare dmatrix
Returns
The matrix exponential of A

Definition at line 67 of file linad99/expm.cpp.

dvar_matrix expm ( const dvar_matrix A)

Matrix exponential.

The matrix exponential is calculated using the Pade approximation adapted from Moler, Cleve; Van Loan, Charles F. (2003), "Nineteen Dubious Ways to Compute the Exponential of a Matrix, Twenty-Five Years Later"

The main use of the matrix exponential is to solve linear ordinary differential equation (ODE) systems:

\[ \frac{d}{dt}y(t) = Ay(t)\ , \ \mbox{with } y(0) = y_0 \]

then the solution becomes

\[ y(t) = e^{At}y_0 \]

Parameters
Asquare dvar_matrix
Returns
The matrix exponential of A

Definition at line 140 of file linad99/expm.cpp.

df1b2matrix expm ( const df1b2matrix A)

Matrix exponential.

The matrix exponential is calculated using the Pade approximation adapted from Moler, Cleve; Van Loan, Charles F. (2003), "Nineteen Dubious Ways to Compute the Exponential of a Matrix, Twenty-Five Years Later"

The main use of the matrix exponential is to solve linear ordinary differential equation (ODE) systems:

\[ \frac{d}{dt}y(t) = Ay(t)\ , \ \mbox{with } y(0) = y_0 \]

then the solution becomes

\[ y(t) = e^{At}y_0 \]

Parameters
Asquare df1b2matrix
Returns
The matrix exponential of A

Definition at line 215 of file df1b2-separable/expm.cpp.

dmatrix inv ( const dmatrix m1)

Inverse of a constant matrix by LU decomposition.

Parameters
m1A dmatrix, $M$, for which the inverse is to be computed.
Returns
A dmatrix containing $M^{-1}$.

The implementation of this algorithm was inspired by "Numerical Recipes in C", 2nd edition, Press, Teukolsky, Vetterling, Flannery, chapter 2

Definition at line 37 of file dmat3.cpp.

double norm ( const dvector t1)

Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.

Norm of a vector; constant objects.

Parameters
t1A vector, $v$.
Returns
$||v|| = (v\times v)^{1/2} = (\sum_i v_i^2)^{1/2}$

Definition at line 13 of file dvect3.cpp.

double norm ( const dmatrix m1)

Norm of a matrix; constant object.

Parameters
m1a matrix, $M$
Returns
$||M||$

Definition at line 31 of file dmat2.cpp.

double norm2 ( const dvector t1)

Squared norm of a vector; constant objects.

Computes the sum of squares of its vector argument.

Parameters
t1A vector, $v$.
Returns
$||v||^2 = v\times v = \sum_i v_i^2$

Definition at line 28 of file dvect3.cpp.

double norm2 ( const dmatrix m1)

Norm squared of a matrix; constant object.

Parameters
m1a matrix, $M$
Returns
$||M||^2$

Definition at line 50 of file dmat2.cpp.

int operator* ( const ivector t1,
const ivector t2 
)

Compute the dot product of two vectors.

The minimum and maxium legal subscripts of the arguments must agree; otherwize an error message is printed and execution terminates.

Parameters
t1A ivector, $a$.
t2A ivector, $b$.
Returns
A int, $z = a\cdot b = \sum_i a_i\cdot b_i$ containing the value of the dot product of the two arguments.

Definition at line 38 of file imat10.cpp.

dvariable operator* ( const dvar_vector v1,
const dvar_vector v2 
)

Compute the dot product of two variable type vectors.

The minimum and maxium legal subscripts of the arguments must agree; otherwize an error message is printed and execution terminates.

Parameters
v1A dvar_vector, $a$.
v2A dvar_vector, $b$.
Returns
A dvariable, $z = a\cdot b = \sum_i a_i\cdot b_i$ containing the value of the dot product of the two arguments.

Definition at line 38 of file fvar_a14.cpp.

double operator* ( const dvector t1,
const dvector t2 
)

Compute the dot product of two vectors.

The minimum and maxium legal subscripts of the arguments must agree; otherwize an error message is printed and execution terminates.

Parameters
t1A dvector, $a$.
t2A dvector, $b$.
Returns
A double, $z = a\cdot b = \sum_i a_i\cdot b_i$ containing the value of the dot product of the two arguments.

Definition at line 512 of file dvector.cpp.

dvector operator* ( const double  x,
const dvector t1 
)

Multiply a dvector by a constant.

Parameters
xDouble constant, $x$.
t1dvector reference, $y$.
Returns
A dvector $z_i = x*y_i$.

Definition at line 630 of file dvector.cpp.

dvector operator+ ( const dvector t1,
const dvector t2 
)

Add two dvectors.

Exits with error if bounds of the two arguments differ.

Parameters
t1dvector reference, $a$.
t2dvector reference, $b$.
Returns
A dvector, $z_i = a_i + b_i$ containing the value of the sum of the two arguments.

Definition at line 554 of file dvector.cpp.

dvector operator- ( const dvector t1,
const dvector t2 
)

Subtract two dvectors.

Exits with error if bounds of the two arguments differ.

Parameters
t1dvector reference, $a$.
t2dvector reference, $b$.
Returns
A dvector, $z_i = a_i - b_i$ containing the value of the difference of the two arguments.

Definition at line 593 of file dvector.cpp.

dvector & dvector::operator= ( const dvector t)

Assignment operator for dvector argument.

Assigns the values of the argument to a target dvector in the LHS of the assignment operator. The range of valid subscripts in the argument and the target must be identical.

Parameters
tA dvector constant
Returns
Reference to a dvector object.

Definition at line 244 of file dvector.cpp.

Referenced by named_dvector::operator=(), and data_vector::operator=().

dvector & dvector::operator= ( double  x)

Assignment operator for double argument.

Assigns a the same value to all members of the vector object.

Parameters
xA double constant.
Returns
Reference to a dvector object.

Definition at line 215 of file dvector.cpp.

independent_variables & independent_variables::operator= ( const dvector t)

Assignment operator for dvector argument.

Assigns the values of the argument to a independent_variables target in the LHS of the assignment operator. The range of valid subscripts in the argument and the target must be identical.

Parameters
tA dvector constant
Returns
Reference to a independent_variables object.

Definition at line 292 of file dvector.cpp.

Referenced by independent_variables::independent_variables(), and independent_variables::operator=().

dvector & dvector::shift ( int  min)
dvariable sum ( const dvar_vector v1)

Compute the sum of a variable type vector.

Parameters
v1A dvar_vector, $a$.
Returns
A dvariable, $s = \sum a $ containing the sum of the vector.

Definition at line 131 of file fvar_a14.cpp.

dvariable sum ( const dvar_matrix m)

Compute the sum of a variable type matrix.

Parameters
v1A dvar_matrix, $A$.
Returns
A dvariable, $s = \sum A $ containing the sum of the matrix.

Definition at line 194 of file fvar_a14.cpp.

double sumsq ( const dmatrix m1)

Calls norm2.

Parameters
m1a matrix, $M$
Returns
norm2 of m1

Definition at line 69 of file dmat2.cpp.

dmatrix trans ( const dmatrix m1)