KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Namespaces | Typedefs | Functions
m_matrix.h File Reference

Definition for the Matrix class, a thin wrapper on the KJB Matrix struct and its related functionality. More...

#include "m/m_matrix.h"
#include "m/m_mat_basic.h"
#include "m/m_mat_io.h"
#include "m_cpp/m_serialization.h"
#include "m_cpp/m_vector.h"
#include "m_cpp/m_concept.h"
#include "l_cpp/l_exception.h"
#include <iosfwd>

Go to the source code of this file.

Classes

class  kjb::Generic_matrix_view< Matrix_type >
 
class  kjb::Matrix
 This class implements matrices, in the linear-algebra sense, with real-valued elements. More...
 

Namespaces

 kjb
 Classes and functions for dealing with trajectory files.
 

Typedefs

typedef Generic_matrix_view
< Matrix > 
kjb::Matrix_view
 
typedef const
Generic_matrix_view< const
Matrix > 
kjb::Const_matrix_view
 
typedef Generic_vector_view
< Matrix > 
kjb::Matrix_vector_view
 
typedef const
Generic_vector_view< const
Matrix > 
kjb::Const_matrix_vector_view
 

Functions

Matrix kjb::create_identity_matrix (int rank)
 Construct an identity matrix of specified rank. More...
 
Matrix kjb::create_identity_matrix (int num_rows, int num_cols)
 Construct a rank-deficient identity matrix with the specified number of rows and columns. More...
 
Matrix kjb::create_zero_matrix (int rows, int columns)
 Construct a zero matrix of specified size. More...
 
Matrix kjb::create_zero_matrix (int size)
 Construct a square zero matrix of specified size. More...
 
Matrix kjb::create_random_matrix (int num_rows, int num_cols)
 
Matrix kjb::create_gauss_random_matrix (int num_rows, int num_cols)
 
Matrix kjb::create_diagonal_matrix (const Matrix::Vec_type &diagonal)
 Construct a diagonal matrix from the specified vector. More...
 
Matrix kjb::create_diagonal_matrix (const Matrix::Vec_type &diagonal, size_t n)
 Construct a "repeating" diagonal matrix from the specified vector. More...
 
Matrix kjb::create_diagonal_matrix (int size, Matrix::Value_type a)
 Construct a diagonal matrix of the specified size, where the diagonal elements are set to the given value. More...
 
Matrix kjb::create_row_matrix (const Vector &)
 Construct a one-row matrix by deep-copying a vector. More...
 
Matrix kjb::create_column_matrix (const Vector &)
 Construct a one-column matrix by deep-copying a vector. More...
 
Matrix kjb::operator* (const Matrix &op1, const Matrix &op2)
 Compute product of this matrix (on the left) and another. More...
 
Matrix kjb::operator* (const Matrix &op1, Matrix::Value_type op2)
 Compute the product of this matrix and a scalar, yielding a new matrix. More...
 
Matrix kjb::operator* (Matrix::Value_type op1, const Matrix &op2)
 Compute product of scalar and matrix, returning a new matrix. More...
 
Matrix kjb::operator/ (const Matrix &op1, Matrix::Value_type op2)
 Compute new matrix equal to lefthand matrix with each entry divided by a scalar value. More...
 
Matrix kjb::operator+ (const Matrix &op1, const Matrix &op2)
 Compute matrix addition, returning a new matrix. More...
 
Matrix kjb::operator+ (const Matrix &op1, double op2)
 Compute matrix addition, returning a new matrix. More...
 
Matrix kjb::operator- (const Matrix &op1, const Matrix &op2)
 Compute matrix difference, returning a new matrix. More...
 
Matrix kjb::shift_rows_by (const Matrix &op1, const Vector &op2)
 Add the same vector to each row, return a new Matrix. More...
 
Matrix kjb::shift_columns_by (const Matrix &op1, const Vector &op2)
 Add the same vector to each column, return a new Matrix. More...
 
Matrix kjb::ew_multiply_rows_by (const Matrix &op1, const Vector &op2)
 Elementwise multiply each row of op1 by a op2, return a new Matrix. More...
 
Matrix kjb::ew_multiply (const Matrix &op1, const Matrix &op2)
 Elementwise product of two matrices. More...
 
Matrix kjb::operator- (const Matrix &op1, double op2)
 Compute matrix difference, returning a new matrix. More...
 
Matrix kjb::operator- (const Matrix &op1)
 Return the additive inverse of this matrix. More...
 
bool kjb::operator== (const Matrix &op1, const Matrix::Impl_type &op2)
 Test for exact equality between two matrices. More...
 
bool kjb::operator== (const Matrix &op1, const Matrix &op2)
 Test for exact equality between two matrices. More...
 
bool kjb::operator!= (const Matrix &op1, const Matrix::Impl_type &op2)
 Test for any difference between two matrices. More...
 
bool kjb::operator!= (const Matrix &op1, const Matrix &op2)
 Test for any difference between two matrices. More...
 
bool kjb::operator== (const Matrix::Impl_type &op1, const Matrix &op2)
 Test for exact equality between two matrices. More...
 
bool kjb::operator!= (const Matrix::Impl_type &op1, const Matrix &op2)
 Test for any difference between two matrices. More...
 
bool kjb::operator< (const Matrix &op1, const Matrix &op2)
 Returns true if a is lexicographically less-than b. More...
 
Matrix kjb::matrix_inverse (const Matrix &op1)
 Invert this matrix. More...
 
Matrix kjb::matrix_transpose (const Matrix &op1)
 Transpose this matrix. More...
 
Matrix kjb::abs (const Matrix &mat)
 Compute the elementwise absolute value of a matrix. More...
 
double kjb::sum_squared_elements (const Matrix &mat)
 Compute the sum of squared elements. More...
 
Matrix::Value_type kjb::max_abs_difference (const Matrix &op1, const Matrix &op2)
 Find the largest difference between two matrices. More...
 
Matrix::Value_type kjb::min (const Matrix &mat)
 Return the minimum value in this matrix. More...
 
Matrix::Value_type kjb::max (const Matrix &mat)
 Return the maximum value in this matrix. More...
 
std::ostream & kjb::operator<< (std::ostream &out, const Matrix &m)
 Display matrix contents in an ASCII format. More...
 
double kjb::det (const Matrix &mat)
 
Matrix kjb::outer_product (const Vector &v1, const Vector &v2)
 
Matrix::Vec_type kjb::sum_matrix_cols (const Matrix &)
 Compute the matrix's sum across columns (a.k.a. row-wise sum) More...
 
Matrix::Vec_type kjb::sum_matrix_rows (const Matrix &)
 Compute the matrix's sum down (a.k.a. columnar sum), like MATLAB. More...
 
Int_matrix kjb::create_int_matrix_from_matrix_floor (const Matrix &)
 Construct an Int_matrix with elements equal to the floor() of a given floating-point Matrix. More...
 
Int_matrix kjb::floor (const Matrix &m)
 
Int_matrix kjb::create_int_matrix_from_matrix_ceil (const Matrix &)
 Construct a matrix with elements equal to the ceiling, ceil() of a given floating-point Matrix. More...
 
Matrix kjb::logical_or (Matrix a, Matrix b)
 returns a matrix with 1s and 0s. 1 if either has a non zero value in that position, 0 otherwise More...
 
Matrix kjb::logical_and (Matrix a, Matrix b)
 returns a matrix with 1s and 0s. 1 if both matricies have a non zero value in that position, 0 otherwise More...
 
Matrix kjb::logical_not (Matrix a)
 returns a matrix with 1s and 0s. 1 if the value is 0, and 0 otherwise. More...
 
Matrix kjb::tile_matrix (Matrix trixy, unsigned m, unsigned n)
 Construct a tiling of the given matrix. More...
 
Matrix kjb::tile_matrix (int tehnum, unsigned m, unsigned n)
 Construct a tiling of the given matrix, in this case, a matrix of the given number with the specified size. More...
 
void kjb::swap (Matrix &m1, Matrix &m2)
 Non-member swap function. More...
 

Detailed Description

Definition for the Matrix class, a thin wrapper on the KJB Matrix struct and its related functionality.

Author
Kyle Simek
Andrew Predoehl
Ernesto Brau
Luca Del Pero

If you make changes to this file, PLEASE CONSIDER making parallel changes to l_int_matrix.h, whose structure closely parallels the structure of this file. Tip: use vimdiff on both files to show the parallel structure.

Although this class has much the same interface as class Int_matrix, they are not derived from a common abstract interface, because (1) we want as much speed as possible – this code should be eligible to put inside a tight inner loop; and (2) I don't know whether that would be useful.