38 #include "m/m_matrix.h"
39 #include "m/m_mat_basic.h"
40 #include "m/m_mat_io.h"
48 #ifdef KJB_HAVE_BST_SERIAL
49 #include <boost/serialization/access.hpp>
53 #include <boost/concept_check.hpp>
75 template <
class Matrix_type>
96 #ifdef KJB_HAVE_BST_SERIAL
97 friend class boost::serialization::access;
129 void compute_row_col(
148 void compute_row_col_carefully(
162 compute_row_col( index, row, col );
166 void throw_bad_bounds(
int row_ix,
int col_ix )
const;
181 ETX( kjb_c::get_target_matrix( &m_matrix, 0, 0 ) );
193 ETX( kjb_c::get_target_matrix( &m_matrix, rows, cols ) );
206 Matrix m( static_cast<int>( rows ), static_cast<int>( cols ) );
220 Matrix m( static_cast<int>( rows ), static_cast<int>( cols ), val );
230 Matrix(
unsigned long rows,
unsigned long cols)
234 Matrix m( static_cast<int>( rows ), static_cast<int>( cols ) );
248 Matrix m( static_cast<int>( rows ), static_cast<int>( cols ), val );
261 ETX( kjb_c::get_initialized_matrix( &m_matrix, rows, cols, num ) );
326 : m_matrix( mat_ptr )
331 ETX( kjb_c::get_target_matrix( &m_matrix, 0, 0 ) );
354 ETX( kjb_c::copy_matrix( &m_matrix, &mat_ref ) );
363 Matrix(
const std::string& file_name);
374 ETX( kjb_c::copy_matrix( &m_matrix, mat_ref.m_matrix ) );
379 #ifdef KJB_HAVE_CXX11
384 : m_matrix( nullptr )
386 m_matrix = mat_ref.m_matrix;
387 mat_ref.m_matrix = 0;
510 #ifdef KJB_HAVE_CXX11
520 m_matrix = other.m_matrix;
546 return m_matrix -> num_rows;
557 return m_matrix -> num_cols;
621 ETX(kjb_c::get_target_matrix(&m_matrix, new_rows, new_cols));
633 int old_rows = m_matrix->num_rows;
634 int old_cols = m_matrix->num_cols;
638 this->
resize(old_rows, old_cols);
675 double trace()
const;
723 throw_bad_bounds( row, col );
770 return m_matrix->elements[0][
i];
784 return m_matrix->elements[0][
i];
800 return m_matrix -> elements[ row ][ col ];
816 return m_matrix -> elements[ row ][ col ];
920 template<
typename OutputIterator>
921 OutputIterator
get_all_rows(OutputIterator result)
const;
928 template<
typename OutputIterator>
929 OutputIterator
get_all_cols(OutputIterator result)
const;
936 template <
class Generic_vector>
937 void set_row(
int row,
const Generic_vector& v);
944 template <
class Iterator>
945 void set_row(
int row, Iterator begin, Iterator end);
953 template <
class Generic_vector>
954 void set_col(
int col,
const Generic_vector& v);
961 template <
class Iterator>
962 void set_col(
int col, Iterator begin, Iterator end);
990 ETX(copy_matrix_block(&result.m_matrix, m_matrix, row, col, num_rows, num_cols));
1009 return kjb_c::read_matrix( &m_matrix, filename );
1021 int write(
const char* filename = 0 )
const
1024 return kjb_c::write_matrix_full_precision( m_matrix, filename );
1039 return kjb_c::write_raw_matrix( m_matrix, filename );
1061 ETX(kjb_c::multiply_matrices(&m_matrix, m_matrix, op2.m_matrix));
1090 ETX(kjb_c::ow_multiply_matrix_by_scalar(m_matrix, op2));
1148 ETX(kjb_c::ow_scale_matrix_rows_by_sums(m_matrix));
1167 ETX(kjb_c::ow_add_matrices(m_matrix, op2.m_matrix));
1204 ETX(kjb_c::ow_subtract_matrices(m_matrix, op2.m_matrix));
1586 int display(
const char* title = NULL)
const;
1638 template <
class View_type>
1639 void init_from_view_(
const View_type& mat_view);
1641 template<
class Archive>
1642 void serialize(Archive &ar,
const unsigned int version)
1655 template<
typename OutputIterator>
1668 template<
typename OutputIterator>
1681 template <
class Generic_vector>
1685 using namespace boost;
1689 typedef typename Generic_vector::value_type Vector_value_type;
1690 BOOST_CONCEPT_ASSERT((Convertible<Vector_value_type, Value_type>));
1693 set_row(row, v.begin(), v.end());
1698 template <
class Iterator>
1701 Iterator it = begin;
1725 template <
class Generic_vector>
1729 using namespace boost;
1733 typedef typename Generic_vector::value_type Vector_value_type;
1734 BOOST_CONCEPT_ASSERT((Convertible<Vector_value_type, Value_type>));
1737 set_col(col, v.begin(), v.end());
1742 template <
class Iterator>
1745 Iterator it = begin;
1768 template <
class View_type>
1769 void Matrix::init_from_view_(
const View_type& mat_view)
1771 Matrix result(mat_view.get_num_rows(), mat_view.get_num_cols() );
1772 for(
int row = 0; row < mat_view.get_num_rows(); ++row )
1774 for(
int col = 0; col < mat_view.get_num_cols(); ++col )
1776 result( row, col ) = mat_view( row, col );
1798 kjb_c::Matrix* result = 0;
1799 ETX( kjb_c::get_identity_matrix( &result, rank ) );
1813 M.
resize(num_rows, num_cols, 0.0);
1826 kjb_c::Matrix* result = 0;
1827 ETX( kjb_c::get_zero_matrix( &result, rows, columns ) );
1855 kjb_c::Matrix* c_mat = NULL;
1894 kjb_c::Matrix* result = 0;
1895 kjb_c::get_identity_matrix(&result, size);
1896 kjb_c::ow_multiply_matrix_by_scalar(result, a);
1932 return Matrix(op1) *= op2;
1945 return Matrix(op1) *= op2;
1972 return Matrix(op1) /= op2;
1984 return Matrix(op1) += op2;
1996 return Matrix(op1) += op2;
2008 return Matrix(op1) -= op2;
2021 return Matrix(op1).shift_rows_by(op2);
2032 return Matrix(op1).shift_columns_by(op2);
2043 return Matrix(op1).ew_multiply_rows_by(op2);
2053 return Matrix(op1).ew_multiply_by(op2);
2066 return Matrix(op1) -= op2;
2078 return op1 * (-1.0);
2117 return !(op1 == op2);
2130 return !(op1 == op2);
2167 return std::lexicographical_compare(
2168 &op1.m_matrix->elements[0][0],
2169 &op1.m_matrix->elements[0][0] + op1.
get_length(),
2170 &op2.m_matrix->elements[0][0],
2171 &op2.m_matrix->elements[0][0] + op1.
get_length());
2194 kjb_c::Matrix* kjb_matrix = 0;
2195 ETX( kjb_c::get_matrix_transpose( &kjb_matrix, op1.
get_c_matrix() ) );
2196 return Matrix(kjb_matrix);
2210 kjb_c::Matrix* result = 0;
2222 kjb_c::Matrix* result = 0;
2224 double res = kjb_c::sum_matrix_elements(result);
Matrix & multiply(Value_type op2)
Multiply this matrix by a scalar, in place.
Definition: m_matrix.h:1099
Int_matrix create_row_matrix(const Int_matrix::Vec_type &vec)
Construct a one-row matrix by deep-copying a vector.
Definition: l_int_matrix.cpp:105
friend bool operator<(const Matrix &op1, const Matrix &op2)
Returns true if a is lexicographically less-than b.
Definition: m_matrix.h:2165
Int_matrix ceil() const
Return the ceil(3) of each element of the matrix.
Definition: m_matrix.cpp:423
Matrix & multiply(const Matrix &op2)
Compute product of this matrix (on the left) and another, and replace this matrix with the result...
Definition: m_matrix.h:1076
#define ETX(a)
Definition: l_exception.h:67
Int_matrix::Value_type max(const Int_matrix &mat)
Return the maximum value in this matrix.
Definition: l_int_matrix.h:1397
void fill_row(int row, Value_type x)
Definition: m_matrix.cpp:628
void convert_to_3d_rotation_matrix(double phi, double x, double y, double z)
Definition: m_matrix.cpp:978
Matrix inverse() const
Invert this matrix.
Definition: m_matrix.cpp:404
static Matrix create_3d_scaling_matrix(double x, double y, double z)
Definition: m_matrix.cpp:1410
static Matrix create_3d_homo_scaling_matrix(double x, double y, double z)
Definition: m_matrix.cpp:1551
Matrix(unsigned long rows, unsigned long cols, Value_type val)
Ctor builds a matrix of specified number of rows and columns.
Definition: m_matrix.h:244
void set_col(int col, const Generic_vector &v)
Replace a column of the matrix with the given vector. "vector" can be any collection of values conver...
Definition: m_matrix.h:1726
Definition: m_concept.h:30
Matrix submatrix(int row, int col, int num_rows, int num_cols) const
Get the submatrix given by the parameters; i.e., get A(row, col, row + num_rows, col + num_cols)...
Definition: m_matrix.h:987
static Matrix create_3d_homo_rotation_matrix(double phi, double x, double y, double z)
Definition: m_matrix.cpp:1238
Matrix & operator/=(Value_type op2)
Divide each entry in the matrix by a scalar value.
Definition: m_matrix.h:1114
Int_matrix threshold(double t) const
Convert to a binary matrix; zero if value is below threshold, one if value is greater than or equal t...
Definition: m_matrix.cpp:439
Object thrown when an argument is of the wrong size or dimensions.
Definition: l_exception.h:426
const Generic_matrix_view< const Matrix > Const_matrix_view
Definition: m_matrix.h:79
void convert_to_3d_homo_scaling_matrix_from_vector(const Vector &vec)
Definition: m_matrix.cpp:1573
double Value_type
data type of the elements
Definition: m_matrix.h:108
void ow_add_col_vector(const Vec_type v)
add a column vector to each column of a matrix, in place
Definition: m_matrix.cpp:1856
Matrix(unsigned long rows, unsigned long cols)
Ctor builds a matrix of specified number of rows and columns.
Definition: m_matrix.h:230
This class implements matrices, in the linear-algebra sense, restricted to integer-valued elements...
Definition: l_int_matrix.h:71
int get_num_rows() const
Return the number of rows in the matrix.
Definition: m_matrix.h:543
int Size_type
size type of the elements
Definition: m_matrix.h:110
Impl_type *& get_underlying_representation_with_guilt()
Get pointer to the underlying kjb_c::Matrix C struct.
Definition: m_matrix.h:591
Matrix & realloc(int new_rows, int new_cols)
resize this matrix, losing previous data. Faster than resize(), because data copy is skipped...
Definition: m_matrix.h:619
void ow_vertical_flip()
flip the matrix vertically (swap last, first row, etc.)
Definition: m_matrix.cpp:1877
Int_matrix::Value_type max_abs_difference(const Int_matrix &op1, const Int_matrix &op2)
Find the largest difference between two matrices.
Definition: l_int_matrix.h:1364
theta
Definition: APPgetLargeConnectedEdges.m:108
Int_matrix create_diagonal_matrix(const Int_matrix::Vec_type &diagonal)
Construct a one-row matrix by deep-copying a vector.
Definition: l_int_matrix.cpp:118
double trace() const
Gets trace of this matrix.
Definition: m_matrix.cpp:667
void convert_to_3d_homo_rotation_matrix(double phi, double x, double y, double z)
Definition: m_matrix.cpp:1180
Matrix 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...
Definition: m_matrix.cpp:2086
double det(const Matrix &mat)
Definition: m_matrix.cpp:1931
Matrix & reserve(int new_rows, int new_cols)
allocate sufficient storage to hold the given dimensions, but leave actual matrix size unchanged...
Definition: m_matrix.h:631
Value_type & at(int i)
Access matrix like a one-dimensional array, using row-major ordering, and returning an lvalue...
Definition: m_matrix.cpp:232
Image operator-(const Image &im1, const Image &im2)
Subtract two images.
Definition: i_image.h:843
#define KJB_THROW(ex)
Definition: l_exception.h:46
Matrix outer_product(const Vector &v1, const Vector &v2)
Definition: m_matrix.h:2293
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
Int_matrix create_column_matrix(const Int_matrix::Vec_type &vec)
Construct a one-column matrix by deep-copying a vector.
Definition: l_int_matrix.cpp:127
Value_type value_type
data type of the elements
Definition: m_matrix.h:109
Matrix & negate()
Transform this matrix into the additive inverse of its former value, in place.
Definition: m_matrix.h:1258
void ow_add_scalar(Value_type c)
add a scalar value to each element of a matrix, in place
Definition: m_matrix.cpp:1842
Matrix & operator=(const Impl_type &mat_ref)
Clone of square version of zero_out(int)
Definition: m_matrix.cpp:189
void set_row(int row, const Generic_vector &v)
Replace a row of the matrix with the given vector.
Definition: m_matrix.h:1682
Matrix(Impl_type *mat_ptr)
Conversion ctor: claim ownership of an existing matrix pointer (i.e., make a shallow copy)...
Definition: m_matrix.h:325
void convert_to_3d_homo_scaling_matrix(double x, double y, double z)
Definition: m_matrix.cpp:1522
void ow_add_row_vector(const Vec_type v)
add a row vector to each row of a matrix, in place
Definition: m_matrix.cpp:1849
void convert_to_3d_homo_translation_matrix_from_vector(const Vector &vec)
Definition: m_matrix.cpp:1706
Matrix(int rows, int cols, Value_type num)
Ctor builds a matrix of specified size, all entries set to num.
Definition: m_matrix.h:257
const Value_type & operator[](int i) const
Subscript matrix like a one-dimensional C array, e.g., A[10], using row-major ordering, and returning an rvalue.
Definition: m_matrix.h:753
Image operator+(const Image &op1, const Image &op2)
Add two images.
Definition: i_image.h:834
Value_type & operator()(int row, int col)
Access matrix like a Fortran or MATLAB two-dimensional array, e.g., A(2,4), and return an lvalue...
Definition: m_matrix.h:797
double abs_of_determinant() const
Gets the absolute value of the determinant of this matrix.
Definition: m_matrix.cpp:413
Matrix create_gauss_random_matrix(int num_rows, int num_cols)
Definition: m_matrix.cpp:344
Value_type & operator[](int i)
Subscript matrix like a one-dimensional C array, e.g., A[10], using row-major ordering, and returning an lvalue.
Definition: m_matrix.h:739
void kjb_serialize(Archive &ar, KJB_readable_writable &obj, const unsigned int version)
Definition: l_serialization.h:170
int write_raw(const char *filename=0) const
Writes the matrix contents to a file specified by name.
Definition: m_matrix.h:1036
~Matrix()
Definition: m_matrix.h:394
Matrix & limit_values(Value_type low, Value_type high)
Make sure all values in this matrix are between the two given values.
Definition: m_matrix.cpp:298
Generic_vector_view< Matrix > Matrix_vector_view
Definition: m_matrix.h:81
Matrix map(Value_type(*f)(Value_type)) const
Definition: m_matrix.h:1592
Matrix matrix_inverse(const Matrix &op1)
Invert this matrix.
Definition: m_matrix.cpp:730
static Matrix create_3d_homo_scaling_matrix_from_vector(const Vector &vec)
Definition: m_matrix.cpp:1615
Matrix Mat_type
the associated matrix type
Definition: m_matrix.h:112
static Matrix create_2d_rotation_matrix(double phi)
Definition: m_matrix.cpp:1059
int get_num_cols() const
Return the number of columns in the matrix.
Definition: m_matrix.h:554
Int_matrix create_int_matrix_from_matrix_ceil(const Matrix &mat)
Construct a matrix with elements equal to the ceiling, ceil() of a given floating-point Matrix...
Definition: m_matrix.cpp:1992
Vector Vec_type
the associated vector type
Definition: m_matrix.h:113
Int_matrix matrix_transpose(const Int_matrix &op1)
Test for any difference between two matrices.
Definition: l_int_matrix.h:1331
static Matrix create_euler_homo_rotation_matrix(float phi, float theta, float psi)
Definition: m_matrix.cpp:952
Matrix & operator=(const Matrix &src)
Assign contents from a kjb::Matrix, a C++ object.
Definition: m_matrix.h:501
Matrix & replace(int row, int col, const Matrix &A)
Replace a submatrix of this matrix with the given matrix.
Definition: m_matrix.cpp:757
void ow_horizontal_flip()
flip the matrix horizontally (swap left, right columns, etc.)
Definition: m_matrix.cpp:1884
kjb_c::Pixel abs(const kjb_c::Pixel &p)
Take the channel-wise absolute value of a kjb_c::Pixel.
Definition: i_pixel.h:354
static Matrix create_3d_scaling_matrix_from_vector(const Vector &vec)
Definition: m_matrix.cpp:1481
Definition: m_mat_view.h:55
Value_type(* Mapper)(Value_type)
element transformer fun
Definition: m_matrix.h:114
x
Definition: APPgetLargeConnectedEdges.m:100
const Value_type & operator()(int row, int col) const
Access matrix like a Fortran or MATLAB two-dimensional array, e.g., A(2,4), and return an rvalue...
Definition: m_matrix.h:813
void convert_to_euler_rotation_matrix(float phi, float theta, float psi)
Creates an euler rotation matrix without reallocating memory, when possible.
Definition: m_matrix.cpp:880
Matrix(const Impl_type &mat_ref)
Ctor copies contents (i.e., a deep copy) of an existing C-struct matrix.
Definition: m_matrix.h:350
Matrix create_zero_matrix(int rows, int columns)
Construct a zero matrix of specified size.
Definition: m_matrix.h:1823
Matrix & add(const Matrix &op2)
Add, in place, a matrix to this matrix.
Definition: m_matrix.h:1183
int size() const
Return the number of elements in the matrix. (alias of get_length)
Definition: m_matrix.h:579
static Matrix create_2d_homo_rotation_matrix(double phi)
Definition: m_matrix.cpp:1263
Vec_type filter(bool(*f)(Value_type))
Definition: m_matrix.cpp:1796
Matrix::Vec_type sum_matrix_rows(const Matrix &m)
Compute the matrix's sum down (a.k.a. columnar sum), like MATLAB.
Definition: m_matrix.cpp:1982
void convert_to_3d_rotation_matrix_from_vector(double phi, const Vector &vec)
Definition: m_matrix.cpp:1083
int display(const char *title=NULL) const
Definition: m_matrix.cpp:1785
void ow_multiply_col_vector_ew(const Vec_type v)
multiply a column vector by each column of a matrix, elementwise, in place
Definition: m_matrix.cpp:1863
Value_type reduce(Value_type(*f)(Value_type x, Value_type y), Value_type init=0.0) const
call function f using every element of the matrix as an input
Definition: m_matrix.cpp:1819
Matrix::Value_type max(const Matrix &mat)
Return the maximum value in this matrix.
Definition: m_matrix.h:2261
Matrix::Vec_type sum_matrix_cols(const Matrix &m)
Compute the matrix's sum across columns (a.k.a. row-wise sum)
Definition: m_matrix.cpp:1972
static Matrix create_euler_rotation_matrix(float phi, float theta, float psi)
Creates an euler rotation matrix and stores it into an instance of claa Matrix.
Definition: m_matrix.cpp:904
Matrix create_identity_matrix(int rank)
Construct an identity matrix of specified rank.
Definition: m_matrix.h:1795
Matrix & zero_out()
Clobber contents of matrix with zeroes.
Definition: m_matrix.cpp:292
Matrix & subtract(const Matrix &op2)
Subtract another matrix from this matrix, in place.
Definition: m_matrix.h:1246
Matrix(const Matrix &mat_ref)
Copy ctor.
Definition: m_matrix.h:370
Indexable ew_multiply(const Indexable &I, const Indexable &J)
Multiply the elements of two Indexable things. Must be indexed via operator() and assignable...
Definition: l_ew.h:43
Mat_type & mapcar(Mapper)
Transform the elements of a matrix.
Definition: m_matrix.cpp:739
std::ofstream & operator<<(std::ofstream &out, const Quaternion &q)
Definition: turntable_camera.cpp:77
Image operator/(const Image &op1, double op2)
Scale an image in channel space, yielding a new image.
Definition: i_image.h:825
Matrix(int rows, int cols)
Ctor builds a matrix of specified number of rows and columns.
Definition: m_matrix.h:189
Vec_type get_diagonal() const
Retrieves the diagonal of this matrix; returned as a vector.
Definition: m_matrix.cpp:652
bool operator!=(const Int_matrix &op1, const Int_matrix::Impl_type &op2)
Test for any difference between two matrices.
Definition: l_int_matrix.h:1274
Value_type & operator()(int i)
MATLAB-style one-dimensional subscript of matrix, e.g., A(10), using row-major ordering, and returning an lvalue.
Definition: m_matrix.h:767
Int_matrix floor() const
Return the floor(3) of each element of the matrix.
Definition: m_matrix.cpp:431
void swap(kjb::Gsl_Multimin_fdf &m1, kjb::Gsl_Multimin_fdf &m2)
Swap two wrapped multimin objects.
Definition: gsl_multimin.h:693
Matrix & divide(Value_type op2)
Divide each entry in the matrix by a scalar value.
Definition: m_matrix.h:1137
bool operator==(const Int_matrix &op1, const Int_matrix::Impl_type &op2)
Test for exact equality between two matrices.
Definition: l_int_matrix.cpp:218
Object thrown when an division is attempted with a zero divisor.
Definition: l_exception.h:450
Vec_type get_row(int row) const
Return a specified row of this matrix, in the form of a Vector.
Definition: m_matrix.cpp:604
Matrix & resize(int new_rows, int new_cols, Value_type pad=Value_type(0))
Resize this matrix, retaining previous values. Space is reused if possible. Otherwise requires a new ...
Definition: m_matrix.cpp:457
Matrix & operator+=(const Matrix &op2)
Add, in place, a matrix to this matrix.
Definition: m_matrix.h:1157
int read(const char *filename=0)
Reads the matrix contents from a file specified by name.
Definition: m_matrix.h:1006
Matrix transpose() const
Transpose this matrix.
Definition: m_matrix.cpp:395
Int_matrix::Value_type min(const Int_matrix &mat)
Return the minimum value in this matrix.
Definition: l_int_matrix.h:1385
Matrix & shift_rows_by(const Vector &v)
Shift each row by a vector, in place.
Definition: m_matrix.cpp:836
int write(const char *filename=0) const
Writes the matrix contents to a file specified by name.
Definition: m_matrix.h:1021
OutputIterator get_all_cols(OutputIterator result) const
Return all columns of this matrix into the provided iterator.
Definition: m_matrix.h:1669
static Matrix create_3d_homo_translation_matrix(double x, double y, double z)
Definition: m_matrix.cpp:1683
Matrix & vertcat(const Matrix &A)
Concat this matrix with another vertically. (named after the equivalent Matlab function) ...
Definition: m_matrix.cpp:774
void convert_to_euler_homo_rotation_matrix(float phi, float theta, float psi)
Definition: m_matrix.cpp:929
void convert_to_3d_scaling_matrix_from_vector(const Vector &vec)
Definition: m_matrix.cpp:1434
Definition: m_vec_view.h:56
Vec_type get_col(int col) const
Return a specified column of this matrix, in the form of a Vector.
Definition: m_matrix.cpp:613
Matrix & ew_multiply_rows_by(const Vector &v)
elementwise multiply each row by a vector, in place
Definition: m_matrix.cpp:852
const Impl_type * get_c_matrix() const
Get const pointer to the underlying kjb_c::Matrix C struct.
Definition: m_matrix.h:601
static Matrix create_3d_homo_rotation_matrix_from_vector(double phi, const Vector &vec)
Definition: m_matrix.cpp:1337
void free_matrix(float **m, long nrl, long nrh, long ncl, long nch)
Definition: nr.cpp:237
Matrix()
Default ctor builds a matrix of zero rows, zero columns.
Definition: m_matrix.h:177
void convert_to_2d_homo_rotation_matrix(double phi)
Definition: m_matrix.cpp:1208
void convert_to_3d_scaling_matrix(double x, double y, double z)
Definition: m_matrix.cpp:1381
get the indices of edges in each direction for i
Definition: APPgetLargeConnectedEdges.m:48
void convert_to_2d_rotation_matrix(double phi)
Definition: m_matrix.cpp:1006
Matrix & shift_columns_by(const Vector &v)
Shift each column by a vector, in place.
Definition: m_matrix.cpp:844
const Value_type & operator()(int i) const
MATLAB-style one-dimensional subscript of matrix, e.g., A(10), using row-major ordering, and returning an rvalue.
Definition: m_matrix.h:781
Matrix & scale_matrix_rows_by_sums()
something luca will document eventually
Definition: m_matrix.h:1146
This class implements matrices, in the linear-algebra sense, with real-valued elements.
Definition: m_matrix.h:94
Matrix 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
Definition: m_matrix.cpp:2032
static Matrix create_3d_rotation_matrix(double phi, double x, double y, double z)
Definition: m_matrix.cpp:1034
for m
Definition: APPgetLargeConnectedEdges.m:64
Matrix & operator-=(const Matrix &op2)
Subtract another matrix from this matrix, in place.
Definition: m_matrix.h:1194
Support for error handling exception classes in libKJB.
void swap(Matrix &other)
Swap the representations of two matrices.
Definition: m_matrix.h:532
Matrix tile_matrix(Matrix orig, unsigned m, unsigned n)
Construct a tiling of the given matrix.
Definition: m_matrix.cpp:2128
int get_length() const
Return the number of elements in the matrix.
Definition: m_matrix.h:566
kjb_c::Matrix Impl_type
the underlying implementation
Definition: m_matrix.h:111
double sum_squared_elements(const Matrix &mat)
Compute the sum of squared elements.
Definition: m_matrix.h:2219
OutputIterator get_all_rows(OutputIterator result) const
Return all rows of this matrix into the provided iterator.
Definition: m_matrix.h:1656
Int_matrix create_int_matrix_from_matrix_floor(const Matrix &mat)
Construct an Int_matrix with elements equal to the floor() of a given floating-point Matrix...
Definition: m_matrix.cpp:2009
Matrix & horzcat(const Matrix &A)
Concat this matrix with another horizontally. (named after the equivalent Matlab function) Because of...
Definition: m_matrix.cpp:796
void fill_col(int col, Value_type x)
Definition: m_matrix.cpp:640
static Matrix create_3d_rotation_matrix_from_vector(double phi, const Vector &vec)
Definition: m_matrix.cpp:1134
Gsl_Vector operator*(double scalar, const Gsl_Vector &vector)
multiply scalar and vector, scalar written on the left side
Definition: gsl_vector.h:661
void convert_to_3d_homo_translation_matrix(double x, double y, double z)
Definition: m_matrix.cpp:1654
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...
void check_bounds(int row, int col) const
Test whether the given row and column indices are valid.
Definition: m_matrix.h:717
Matrix(unsigned rows, unsigned cols, Value_type val)
Ctor builds a matrix of specified number of rows and columns.
Definition: m_matrix.h:216
void convert_to_3d_homo_rotation_matrix_from_vector(double phi, const Vector &vec)
Definition: m_matrix.cpp:1286
Matrix & operator*=(const Matrix &op2)
Compute product of this matrix (on the left) and another, and replace this matrix with the result...
Definition: m_matrix.h:1059
Matrix & ew_multiply_by(const Matrix &m)
elementwise multiply by another matrix
Definition: m_matrix.cpp:860
const Generic_vector_view< const Matrix > Const_matrix_vector_view
Definition: m_matrix.h:82
Matrix create_random_matrix(int num_rows, int num_cols)
Definition: m_matrix.h:1853
Generic_matrix_view< Matrix > Matrix_view
Definition: m_matrix.h:76
static Matrix create_3d_homo_translation_matrix_from_vector(const Vector &vec)
Definition: m_matrix.cpp:1753
void ow_multiply_row_vector_ew(const Vec_type v)
multiply a row vector by each row of a matrix, elementwise, in place
Definition: m_matrix.cpp:1870
Matrix(unsigned rows, unsigned cols)
Ctor builds a matrix of specified number of rows and columns.
Definition: m_matrix.h:202
Matrix logical_not(Matrix a)
returns a matrix with 1s and 0s. 1 if the value is 0, and 0 otherwise.
Definition: m_matrix.cpp:2108