46 #ifndef _NUMMAT_IMPL_HPP_
47 #define _NUMMAT_IMPL_HPP_
54 #ifdef _NUMMAT_VECTOR_
55 inline void SetValue(BolNumMat& M,
bool val)
57 std::fill(M.Container()->begin(),M.Container()->end(),(char)val);
63 #ifdef _NUMMAT_VECTOR_
64 std::fill(M.Container()->begin(),M.Container()->end(),val);
66 std::fill(M.Data(),M.Data()+M.m()*M.n(),val);
74 for (Int i=0; i < M.m()*M.n(); i++)
75 sum += abs(ptr[i]) * abs(ptr[i]);
80 template <
class F>
inline void
81 Transpose (
const NumMat<F>& A, NumMat<F>& B )
84 PushCallStack(
"Transpose");
86 if( A.m() != B.n() || A.n() != B.m() ){
87 B.Resize( A.n(), A.m() );
92 Int m = A.m(), n = A.n();
94 for( Int i = 0; i < m; i++ ){
95 for( Int j = 0; j < n; j++ ){
96 Bdata[ j + n*i ] = Adata[ i + j*m ];
107 template <
class F>
inline void
108 Symmetrize( NumMat<F>& A )
111 PushCallStack(
"Symmetrize");
113 if( A.m() != A.n() ){
114 throw std::logic_error(
"The matrix to be symmetrized should be a square matrix." );
125 for( Int i = 0; i < A.m() * A.n(); i++ ){
126 *Adata = half * (*Adata + *Bdata);
140 #endif // _NUMMAT_IMPL_HPP_
Real Energy(const NumMat< F > &M)
Energy computes the L2 norm of a matrix (treated as a vector).
Definition: nummat_impl.hpp:70
void SetValue(NumMat< F > &M, F val)
SetValue sets a numerical matrix to a constant val.
Definition: nummat_impl.hpp:61
Numerical matrix.
Definition: nummat_decl.hpp:93