2 #ifndef vnl_diag_matrix_fixed_h_ 3 #define vnl_diag_matrix_fixed_h_ 23 # include <vcl_msvc_warnings.h> 27 #include "vnl/vnl_export.h" 39 template <
class T,
unsigned int N>
71 T determinant()
const;
77 inline T operator () (
unsigned i,
unsigned j)
const {
78 return (i != j) ? T(0) : diagonal_[i];
81 inline T& operator () (
unsigned i,
unsigned j) {
87 inline T& operator() (
unsigned i) {
return diagonal_[i]; }
88 inline T
const& operator() (
unsigned i)
const {
return diagonal_[i]; }
90 inline T& operator[] (
unsigned i) {
return diagonal_[i]; }
91 inline T
const& operator[] (
unsigned i)
const {
return diagonal_[i]; }
117 inline unsigned int size()
const {
return diagonal_.
size(); }
120 inline unsigned int rows()
const {
return diagonal_.
size(); }
124 inline unsigned int cols()
const {
return diagonal_.
size(); }
131 inline void put (
unsigned r,
unsigned c, T
const&
v)
135 #if VNL_CONFIG_CHECK_BOUNDS 136 if (r >= this->size())
143 inline T
get (
unsigned r,
unsigned c)
const 147 #if VNL_CONFIG_CHECK_BOUNDS 148 if (r >= this->size())
176 template <
class T,
unsigned int N> VNL_EXPORT
180 template <
class T,
unsigned int N>
184 for (
unsigned i = 0; i < N; ++i)
187 for (j = 0; j < i; ++j)
189 for (j = i+1; j < N; ++j)
191 ret(i,i) = diagonal_[i];
198 template <
class T,
unsigned int N>
203 for (
unsigned i = 0; i < N; ++i)
209 template <
class T,
unsigned int N>
213 T
const* d = data_block();
214 for (
unsigned i = 0; i < N; ++i)
221 template <
class T,
unsigned int N>
225 for (
unsigned i = 0; i < N; ++i)
233 template <
class T,
unsigned int R,
unsigned int C>
237 for (
unsigned i = 0; i < R; ++i)
238 for (
unsigned j = 0; j < C; ++j)
239 ret(i,j) = A(i,j) * D(j,j);
246 template <
class T,
unsigned int R,
unsigned int C>
251 for (
unsigned i = 0; i < R; ++i)
252 for (
unsigned j = 0; j < C; ++j)
253 ret(i,j) = A(i,j) * d[i];
259 template <
class T,
unsigned int N>
263 for (
unsigned i = 0; i < N; ++i)
271 template <
class T,
unsigned int N>
276 for (
unsigned j = 0; j < N; ++j)
284 template <
class T,
unsigned int N>
292 template <
class T,
unsigned int N>
296 for (
unsigned i = 0; i < N; ++i)
304 template <
class T,
unsigned int N>
309 for (
unsigned j = 0; j < N; ++j)
317 template <
class T,
unsigned int N>
322 for (
unsigned i = 0; i < N; ++i)
324 for (
unsigned j = 0; j < i; ++j)
326 for (
unsigned j = i+1; j < N; ++j)
328 ret(i,i) = d[i] - A(i,i);
336 template <
class T,
unsigned int N>
345 template <
class T,
unsigned int N>
351 #endif // vnl_diag_matrix_fixed_h_ T determinant() const
Return determinant as product of diagonal values.
vnl_bignum operator+(vnl_bignum const &r1, long r2)
Returns the sum of two bignum numbers.
vnl_vector_fixed< T, N > get_diagonal() const
Return a vector (copy) with the content of the (main) diagonal.
vnl_vector_fixed< T, N >::const_iterator const_iterator
vnl_diag_matrix_fixed & operator=(vnl_diag_matrix_fixed< T, N > const &that)
unsigned int cols() const
Return the number of columns.
vnl_diag_matrix_fixed & fill_diagonal(T const &v)
Set all diagonal elements of matrix to specified value.
vnl_vector_fixed< T, n > element_product(const vnl_vector_fixed< T, n > &a, const vnl_vector_fixed< T, n > &b)
unsigned int size() const
Length of the vector.
vnl_diag_matrix_fixed & invert_in_place()
Invert a vnl_diag_matrix_fixed in-situ, then returns *this.
vnl_diag_matrix_fixed(T const &value)
Construct a diagonal matrix with diagonal elements equal to value.
void vnl_error_matrix_row_index(char const *fcn, int r)
Raise exception for invalid row index.
Fixed size, stack-stored, space-efficient matrix.
vnl_vector_fixed & fill(T const &v)
Set all values to v.
vnl_matrix_fixed< T, N, N > as_matrix_fixed() const
Convert a vnl_diag_matrix_fixed to a Matrix.
vnl_diag_matrix_fixed< T, N > & operator/=(T v)
In-place arithmetic operation.
unsigned int size() const
Return the total number of elements stored by the matrix.
vnl_vector_fixed< T, N > const & diagonal() const
Return diagonal elements as a vector.
std::ostream & operator<<(std::ostream &s, vnl_decnum const &r)
decimal output.
void put(unsigned r, unsigned c, T const &v)
set element with boundary checks.
vnl_diag_matrix_fixed & fill(T const &x)
unsigned int rows() const
Return the number of rows.
T const * data_block() const
vnl_vector_fixed< T, N > diagonal_
T get(unsigned r, unsigned c) const
get element with boundary checks.
T const * data_block() const
Access the contiguous block storing the elements in the vector.
vnl_diag_matrix_fixed & set(vnl_vector_fixed< T, N > const &v)
Set diagonal elements using vector, then return *this.
unsigned int columns() const
Return the number of columns.
Fixed length stack-stored vector.
stores a diagonal matrix as a single vector.
vnl_matrix_fixed< T, N, N > as_ref() const
vnl_bignum operator-(vnl_bignum const &r1, vnl_bignum const &r2)
Returns the difference of two bignum numbers.
vnl_diag_matrix_fixed(vnl_vector_fixed< T, N > const &that)
Construct a diagonal matrix from a vnl_vector_fixed.
T * data_block()
Return pointer to the diagonal elements as a contiguous 1D C array;.
vnl_vector_fixed< T, N >::iterator iterator
vnl_bignum operator *(vnl_bignum const &r1, vnl_bignum const &r2)
Returns the product of two bignum numbers.
vnl_diag_matrix_fixed & set_diagonal(vnl_vector_fixed< T, N > const &v)
Sets the diagonal elements of this matrix to the specified list of values.