matrix.h File Reference

Holds the ml_matrix class definitions. More...

Go to the source code of this file.

Classes

class  ml_matrix
 Class definition for ml_matrix.


Defines

#define ML_FP_TOL   1e-08
 Defines the smallest floating point number to compensate for machine epsilon.

#define ML_COLUMN_MAJOR
 Determines whether array data is internally stored by columns (FORTRAN storage) or by rows (C storage).


Enumerations

enum  ml_error_codes {
  ml_no_error = 0, ml_bad_index = 1, ml_size_mismatch = 2, ml_non_invertible_matrix = 3,
  ml_bad_file_pointer = 4, ml_bad_range = 5, ml_bad_operand = 6, ml_bad_string_format = 7,
  ml_invalid_buffer = 8, ml_lapack_error = 9
}
 Error codes for invalid matrix operations. More...


Functions

ml_matrix linspace (double start, double finish, int n)
 Creates a linearly spaced vector with n points between two values.

ml_matrix colon (double start, double incr, double end)
 Creates a vector using a fixed increment between two points.

ml_matrix append_identity (const ml_matrix &b)
 Adds an appropriately sized identity matrix to the existing matrix.

ml_matrix dup_rows (const ml_matrix &m, int num)
 Returns a new matrix with the specified matrix duplicated row-wise a given number of times.

ml_matrix dup_cols (const ml_matrix &m, int num)
 Returns a new matrix with the specified matrix duplicated column-wise a given number of times.

ml_matrix append (const ml_matrix &a, const ml_matrix &b)
 Returns a new matrix with the columns from the two matrices appended side by side.

ml_matrix stack (const ml_matrix &a, const ml_matrix &b)
 Returns a new matrix with the rows from the second matrix stacked below the rows of the first matrix.

ml_matrix sort (const ml_matrix &m, int direction=0)
 Sorts all the elements of the matrix. Ascending order is the default, pass a non-zero value for descending sort.

ml_matrix apply (const ml_matrix &m, double(*func)(double))
 Applies a specified function to every element in the matrix.

ml_matrix operator * (double b, const ml_matrix &a)
 Scalar multiplication operator.

ml_matrix operator * (const ml_matrix &a, double b)
 Scalar multiplication operator.

ml_matrix operator * (const ml_matrix &a, const ml_matrix &b)
 Matrix multiplication operator.

ml_matrix dotstar (const ml_matrix &a, const ml_matrix &b)
 Element by element multiplication, returning the results as a new matrix.

ml_matrix operator/ (const ml_matrix &a, double b)
 Scalar division operator.

ml_matrix operator/ (const ml_matrix &a, const ml_matrix &b)
 Matrix division operator.

ml_matrix backslash (const ml_matrix &a, const ml_matrix &b)
 Backslash operator performs inverse(a) * b.

ml_matrix dotslash (const ml_matrix &a, const ml_matrix &b)
 Element by element division, returning the results as a new matrix.

ml_matrix operator+ (double b, const ml_matrix &a)
 Scalar addition operator.

ml_matrix operator+ (const ml_matrix &a, double b)
 Scalar addition operator.

ml_matrix operator+ (const ml_matrix &a, const ml_matrix &b)
 Matrix addition operator, adds corresponding elements.

ml_matrix operator- (double b, const ml_matrix &a)
 Scalar subtraction operator.

ml_matrix operator- (const ml_matrix &a, double b)
 Scalar subtraction operator.

ml_matrix operator- (const ml_matrix &a, const ml_matrix &b)
 Matrix subtraction operator, adds corresponding elements.

ml_matrix operator- (const ml_matrix &a)
 Matrix negation operator, returns the negative of each element.

ml_matrix abs (const ml_matrix &x)
 Absolute value function - changes all values in the matrix to the absolute value of the element.

ml_matrix ceil (const ml_matrix &x)
 Changes each element to the smallest integer greater than or equal to that element.

ml_matrix floor (const ml_matrix &x)
 Changes each element to the largest integer less than or equal to that element.

ml_matrix round (const ml_matrix &x)
 Rounds each element to the nearest integral value, rounding half-way cases away from zero.

ml_matrix rint (const ml_matrix &x)
 Rounds each element to the nearest integral value according to the prevailing rounding mode.

ml_matrix dotpow (const ml_matrix &, double n)
 Raises each element of the matrix to the given power.

ml_matrix sqrt (const ml_matrix &x)
 Returns the square root of each element.

ml_matrix exp (const ml_matrix &x)
 Calls the std::exp() function on each element in the matrix.

ml_matrix expm1 (const ml_matrix &x)
 Calls the std::expm1() function on each element in the matrix.

ml_matrix log (const ml_matrix &x)
 Calls the std::log() function on each element in the matrix.

ml_matrix log10 (const ml_matrix &x)
 Calls the std::log10() function on each element in the matrix.

ml_matrix log1p (const ml_matrix &x)
 Calls the std::log1p() function on each element in the matrix.

ml_matrix log2 (const ml_matrix &x)
 Calls the std::log2() function on each element in the matrix.

ml_matrix logb (const ml_matrix &x)
 Calls the std::logb() function on each element in the matrix.

ml_matrix transpose (const ml_matrix &m)
 Transposes the matrix.

ml_matrix inv (const ml_matrix &m)
 Finds the inverse of the matrix. Principally used for matrix division.

ml_matrix mpow (const ml_matrix &m, int n)
 Raises the matrix m to the power n.

ml_matrix cross (const ml_matrix &m, const ml_matrix &y)
 Crosses the two matrices.

ml_matrix unit (const ml_matrix &m)
 Makes each column into a row vector.

ml_matrix sign (const ml_matrix &m)
 Changes all positive elements into 1, all negative elements into -1.

ml_matrix svd (ml_matrix &u, ml_matrix &v, const ml_matrix &a)
 Returns the singular value decomposition of the third matrix.

ml_matrix vunit (const ml_matrix &m)
 Converts the matrix into a unit vector.

ml_matrix solve_ax_eq_b (const ml_matrix &a, const ml_matrix &b)
 Solve AX=B.

bool simplex (ml_matrix &x, ml_matrix c, ml_matrix a, ml_matrix b, double max_val)
 Uses the simplex method to minimize the cost when solving the problem au = b and the cost is cu.

void simplex2 (ml_matrix a, ml_matrix c, ml_matrix &x, ml_int_array &s, ml_int_array &g, ml_int_array &gu, ml_matrix &b_inv, double max_val)
 Computes the solution to the simplex problem with an optional maximum constraint.

ml_matrix sin (const ml_matrix &x)
 Returns the element by element sin of the matrix.

ml_matrix cos (const ml_matrix &x)
 Returns the element by element cosine of the matrix.

ml_matrix tan (const ml_matrix &x)
 Returns the element by element tangent of the matrix.

ml_matrix csc (const ml_matrix &x)
 Returns the element by element cosecant of the matrix.

ml_matrix sec (const ml_matrix &x)
 Returns the element by element secant of the matrix.

ml_matrix cot (const ml_matrix &x)
 Returns the element by element cotangent of the matrix.

ml_matrix asin (const ml_matrix &x)
 Returns the element by element arcsine of the matrix.

ml_matrix acos (const ml_matrix &x)
 Returns the element by element arccosine of the matrix.

ml_matrix atan (const ml_matrix &x)
 Returns the element by element arctangent of the matrix.

ml_matrix acsc (const ml_matrix &x)
 Returns the element by element arccosecant of the matrix.

ml_matrix asec (const ml_matrix &x)
 Returns the element by element arcsecant of the matrix.

ml_matrix acot (const ml_matrix &x)
 Returns the element by element arccotangent of the matrix.

ml_matrix atan2 (const ml_matrix &x, const ml_matrix &y)
 Returns the element by element arctangent"2" of the matrix with respect to the 2nd matrix.

ml_matrix sinh (const ml_matrix &x)
 Returns the element by element hyperbolic sine of the matrix.

ml_matrix cosh (const ml_matrix &x)
 Returns the element by element hyperbolic cosine of the matrix.

ml_matrix tanh (const ml_matrix &x)
 Returns the element by element hyperbolic tangent of the matrix.

ml_matrix csch (const ml_matrix &x)
 Returns the element by element hyperbolic cosecant of the matrix.

ml_matrix sech (const ml_matrix &x)
 Returns the element by element hyperbolic secant of the matrix.

ml_matrix coth (const ml_matrix &x)
 Returns the element by element hyperbolic cotangent of the matrix.

ml_matrix asinh (const ml_matrix &x)
 Returns the element by element hyperbolic arcsine of the matrix.

ml_matrix acosh (const ml_matrix &x)
 Returns the element by element hyperbolic arccosine of the matrix.

ml_matrix atanh (const ml_matrix &x)
 Returns the element by element hyperbolic arctangent of the matrix.

ml_matrix acsch (const ml_matrix &x)
 Returns the element by element hyperbolic arccosecant of the matrix.

ml_matrix asech (const ml_matrix &x)
 Returns the element by element hyperbolic arcsecant of the matrix.

ml_matrix acoth (const ml_matrix &x)
 Returns the element by element hyperbolic arccotangent of the matrix.


Detailed Description


Enumeration Type Documentation

enum ml_error_codes
 

Enumeration values:
ml_no_error  No error reported.
ml_bad_index  Attempt to access an invalid row or column value.
ml_size_mismatch  The size of a matrix was incorrect for a given operation.
ml_non_invertible_matrix  Occurs when inv() is called on a matrix that does not have an inverse.
ml_bad_file_pointer  Occurs when a matrix is constructed from an invalid file.
ml_bad_range  Occurs when a submatrixing call has row or column information which is invalid.
ml_bad_operand  Generally indicates an attempt to divide by zero.
ml_bad_string_format  Occurs when a matrix is constructed from an invalid string.
ml_invalid_buffer  Indicates a corrupted data buffer.
ml_lapack_error  LAPACK reported an error in a function call.