Vector and Matrix Operations.

## Functions

dvector colsum (const dmatrix &v)
Sum of the elements in each row of a matrix; constant object.
double det (const dmatrix &m1)
Compute determinant of a constant matrix.
dvector elem_div (const dvector &t1, const dvector &t2)
Element-wise division of two vectors; constant objects.
dvector elem_prod (const dvector &t1, const dvector &t2)
Element-wise multiplication of two vectors; constant objects.
dmatrix expm (const dmatrix &A)
Matrix exponential.
dvar_matrix expm (const dvar_matrix &A)
Matrix exponential.
df1b2matrix expm (const df1b2matrix &A)
Matrix exponential.
dmatrix inv (const dmatrix &m1)
Inverse of a constant matrix by LU decomposition.
double norm (const dvector &t1)
Norm of a vector; constant objects.
double norm (const dmatrix &m1)
Norm of a matrix; constant object.
double norm2 (const dvector &t1)
Squared norm of a vector; constant objects.
double norm2 (const dmatrix &m1)
Norm squared of a matrix; constant object.
dvariable operator* (const dvar_vector &v1, const dvar_vector &v2)
Compute the dot product of two variable type vectors.
int operator* (const ivector &t1, const ivector &t2)
Compute the dot product of two vectors.
double operator* (const dvector &t1, const dvector &t2)
Compute the dot product of two vectors.
dvector operator* (const double x, const dvector &t1)
Multiply a dvector by a constant.
dvector operator+ (const dvector &t1, const dvector &t2)
dvector operator- (const dvector &t1, const dvector &t2)
Subtract two dvectors.
dvectordvector::operator= (const dvector &t)
Assignment operator for dvector argument.
dvectordvector::operator= (double x)
Assignment operator for double argument.
independent_variablesindependent_variables::operator= (const dvector &t)
Assignment operator for dvector argument.
dvector rowsum (const dmatrix &v)
Sum of the elements in each column of a matrix; constant object.
dvectordvector::shift (int min)
Shift valid range of subscripts.
dvariable sum (const dvar_vector &v1)
Compute the sum of a variable type vector.
dvariable sum (const dvar_matrix &m)
Compute the sum of a variable type matrix.
dmatrix trans (const dmatrix &m1)
Transpose of a matrix; constant objects.

## 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

 dvector colsum ( const dmatrix & v )

Sum of the elements in each row of a matrix; constant object.

Parameters:
 v Reference to a matrix.
Returns:
A dvector, , of length equal to the number of columns in the matrix.

Definition at line 34 of file dvect12.cpp.

 double det ( const dmatrix & m1 )

Compute determinant of a constant matrix.

\param m1 A dmatrix, \form#28, for which the determinant is computed.
\return A double containing \form#36.
\n\n The implementation of this algorithm was inspired by
"Numerical Recipes in C", 2nd edition,
Press, Teukolsky, Vetterling, Flannery, chapter 2
Deprecated:
Scheduled for replacement by 2010.

Definition at line 438 of file dmat3.cpp.

Referenced by det().

 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:
 t1 A vector, with valid subscripts in t2 A vector, with valid subscripts in
Returns:
A vector containing .

Definition at line 52 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:
 t1 A vector, with valid subscripts in t2 A vector, with valid subscripts in
Returns:
A vector containing .

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:

then the solution becomes

Parameters:
 A square dmatrix
Returns:
The matrix exponential of A

Definition at line 63 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:

then the solution becomes

Parameters:
 A square dvar_matrix
Returns:
The matrix exponential of A

Definition at line 136 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:

then the solution becomes

Parameters:
 A square df1b2matrix
Returns:
The matrix exponential of A

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

 dmatrix inv ( const dmatrix & m1 )

Inverse of a constant matrix by LU decomposition.

Parameters:
 m1 A dmatrix, , for which the inverse is to be computed.
Returns:
A dmatrix containing .

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

Definition at line 36 of file dmat3.cpp.

 double norm ( const dvector & t1 )

Norm of a vector; constant objects.

Parameters:
 t1 A vector, .
Returns:

Definition at line 18 of file dvect3.cpp.

 double norm ( const dmatrix & m1 )

Norm of a matrix; constant object.

Parameters:
 m1 a matrix,
Returns:

Definition at line 38 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:
 t1 A vector, .
Returns:

Definition at line 34 of file dvect3.cpp.

 double norm2 ( const dmatrix & m1 )

Norm squared of a matrix; constant object.

Parameters:
 m1 a matrix,
Returns:

Definition at line 54 of file dmat2.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:
 v1 A dvar_vector, . v2 A dvar_vector, .
Returns:
A dvariable, containing the value of the dot product of the two arguments.

Definition at line 35 of file fvar_a14.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:
 t1 A ivector, . t2 A ivector, .
Returns:
A int, containing the value of the dot product of the two arguments.

Definition at line 40 of file imat10.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:
 t1 A dvector, . t2 A dvector, .
Returns:
A double, containing the value of the dot product of the two arguments.

Definition at line 524 of file dvector.cpp.

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

Multiply a dvector by a constant.

Parameters:
 x Double constant, . t1 dvector reference, .
Returns:
A dvector .

Definition at line 647 of file dvector.cpp.

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

Exits with error if bounds of the two arguments differ.

Parameters:
 t1 dvector reference, . t2 dvector reference, .
Returns:
A dvector, containing the value of the sum of the two arguments.

Definition at line 571 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:
 t1 dvector reference, . t2 dvector reference, .
Returns:
A dvector, containing the value of the difference of the two arguments.

Definition at line 610 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:
 t A dvector constant
Returns:
Reference to a dvector object.

Reimplemented in independent_variables, dll_data_vector, data_vector, and named_dvector.

Definition at line 258 of file dvector.cpp.

 dvector & dvector::operator= ( double x )

Assignment operator for double argument.

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

Parameters:
 x A double constant.
Returns:
Reference to a dvector object.

Reimplemented in data_vector, and named_dvector.

Definition at line 231 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:
 t A dvector constant
Returns:
Reference to a independent_variables object.

Reimplemented from dvector.

Definition at line 304 of file dvector.cpp.

 dvector rowsum ( const dmatrix & v )

Sum of the elements in each column of a matrix; constant object.

Parameters:
 v Reference to a matrix.
Returns:
A dvector, , of length equal to the number of rows in the matrix.

Definition at line 61 of file dvect12.cpp.

Referenced by expm().

 dvector & dvector::shift ( int min )

Shift valid range of subscripts.

Parameters:
 min Ingeger value subtracted from the subscripts
Returns:
A devector containing shifted vector.

Definition at line 54 of file dvector.cpp.

 dvariable sum ( const dvar_vector & v1 )

Compute the sum of a variable type vector.

Parameters:
 v1 A dvar_vector, .
Returns:
A dvariable, containing the sum of the vector.

Definition at line 133 of file fvar_a14.cpp.

 dvariable sum ( const dvar_matrix & m )

Compute the sum of a variable type matrix.

Parameters:
 v1 A dvar_matrix, .
Returns:
A dvariable, containing the sum of the matrix.

Definition at line 187 of file fvar_a14.cpp.

 dmatrix trans ( const dmatrix & m1 )

Transpose of a matrix; constant objects.

Parameters:
 m1 The matrix, , to be transposed.
Returns:

Definition at line 18 of file dmat2.cpp.