glucat  0.8.4
matrix.h
Go to the documentation of this file.
1 #ifndef _GLUCAT_MATRIX_H
2 #define _GLUCAT_MATRIX_H
3 /***************************************************************************
4  GluCat : Generic library of universal Clifford algebra templates
5  matrix.h : Declare common matrix functions
6  -------------------
7  begin : Sun 2001-12-09
8  copyright : (C) 2001-2012 by Paul C. Leopardi
9  : uBLAS interface contributed by Joerg Walter
10  ***************************************************************************
11 
12  This library is free software: you can redistribute it and/or modify
13  it under the terms of the GNU Lesser General Public License as published
14  by the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  This library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU Lesser General Public License for more details.
21 
22  You should have received a copy of the GNU Lesser General Public License
23  along with this library. If not, see <http://www.gnu.org/licenses/>.
24 
25  ***************************************************************************
26  This library is based on a prototype written by Arvind Raja and was
27  licensed under the LGPL with permission of the author. See Arvind Raja,
28  "Object-oriented implementations of Clifford algebras in C++: a prototype",
29  in Ablamowicz, Lounesto and Parra (eds.)
30  "Clifford algebras with numeric and symbolic computations", Birkhauser, 1996.
31  ***************************************************************************
32  See also Arvind Raja's original header comments in glucat.h
33  ***************************************************************************/
34 
35 #include <boost/numeric/ublas/fwd.hpp>
36 
37 #include <complex>
38 
39 namespace glucat
40 {
41  namespace ublas = boost::numeric::ublas;
42 
43  namespace matrix
44  {
46  template< typename LHS_T, typename RHS_T >
47  const
48  RHS_T
49  kron(const LHS_T& lhs, const RHS_T& rhs);
50 
52  template< typename LHS_T, typename RHS_T >
53  const
54  RHS_T
55  mono_kron(const LHS_T& lhs, const RHS_T& rhs);
56 
58  template< typename LHS_T, typename RHS_T >
59  const
60  RHS_T
61  nork(const LHS_T& lhs, const RHS_T& rhs, const bool mono = true);
62 
64  template< typename LHS_T, typename RHS_T >
65  const
66  RHS_T
67  signed_perm_nork(const LHS_T& lhs, const RHS_T& rhs);
68 
70  template< typename Matrix_T >
71  typename Matrix_T::size_type
72  nnz(const Matrix_T& m);
73 
75  template< typename Matrix_T >
76  bool
77  isnan(const Matrix_T& m);
78 
80  template< typename Matrix_T >
81  const
82  Matrix_T
83  unit(const typename Matrix_T::size_type n);
84 
86  template< typename LHS_T, typename RHS_T >
87  const
88  typename RHS_T::expression_type
89  mono_prod(const ublas::matrix_expression<LHS_T>& lhs,
90  const ublas::matrix_expression<RHS_T>& rhs);
91 
93  template< typename LHS_T, typename RHS_T >
94  const
95  typename RHS_T::expression_type
96  sparse_prod(const ublas::matrix_expression<LHS_T>& lhs,
97  const ublas::matrix_expression<RHS_T>& rhs);
98 
100  template< typename LHS_T, typename RHS_T >
101  const
102  typename RHS_T::expression_type
103  prod(const ublas::matrix_expression<LHS_T>& lhs,
104  const ublas::matrix_expression<RHS_T>& rhs);
105 
107  template< typename Scalar_T, typename LHS_T, typename RHS_T >
108  Scalar_T
109  inner(const LHS_T& lhs, const RHS_T& rhs);
110 
112  template< typename Matrix_T >
113  typename Matrix_T::value_type
114  norm_frob2(const Matrix_T& val);
115 
117  template< typename Matrix_T >
118  typename Matrix_T::value_type
119  trace(const Matrix_T& val);
120 
122  template< typename Matrix_T >
123  ublas::vector< std::complex<double> >
124  eigenvalues(const Matrix_T& val);
125 
128 
130  template< typename Matrix_T >
131  struct eig_genus
132  {
133  typedef typename Matrix_T::value_type Scalar_T;
138  };
139 
141  template< typename Matrix_T >
142  eig_genus<Matrix_T>
143  classify_eigenvalues(const Matrix_T& val);
144  }
145 }
146 
147 #endif // _GLUCAT_MATRIX_H
glucat::matrix::eig_genus::Scalar_T
Matrix_T::value_type Scalar_T
Definition: matrix.h:193
glucat::matrix::norm_frob2
Matrix_T::value_type norm_frob2(const Matrix_T &val)
Square of Frobenius norm.
Definition: matrix_imp.h:475
glucat::matrix::mono_kron
const RHS_T mono_kron(const LHS_T &lhs, const RHS_T &rhs)
Sparse Kronecker tensor product of monomial matrices.
Definition: matrix_imp.h:178
glucat::matrix::eig_case_t
eig_case_t
Classification of eigenvalues of a matrix.
Definition: matrix.h:187
glucat::matrix::isnan
bool isnan(const Matrix_T &m)
Not a Number.
Definition: matrix_imp.h:354
glucat::matrix::trace
Matrix_T::value_type trace(const Matrix_T &val)
Matrix trace.
Definition: matrix_imp.h:499
glucat::matrix::unit
const Matrix_T unit(const typename Matrix_T::size_type n)
Unit matrix - as per Matlab eye.
Definition: matrix_imp.h:379
glucat::matrix::sparse_prod
const RHS_T::expression_type sparse_prod(const ublas::matrix_expression< LHS_T > &lhs, const ublas::matrix_expression< RHS_T > &rhs)
Product of sparse matrices.
Definition: matrix_imp.h:424
glucat::matrix::eig_genus::m_eig_case
eig_case_t m_eig_case
What kind of eigenvalues does the matrix contain?
Definition: matrix.h:195
glucat::matrix::mono_prod
const RHS_T::expression_type mono_prod(const ublas::matrix_expression< LHS_T > &lhs, const ublas::matrix_expression< RHS_T > &rhs)
Product of monomial matrices.
Definition: matrix_imp.h:388
glucat::matrix::kron
const RHS_T kron(const LHS_T &lhs, const RHS_T &rhs)
Kronecker tensor product of matrices - as per Matlab kron.
Definition: matrix_imp.h:135
glucat::matrix::nnz
Matrix_T::size_type nnz(const Matrix_T &m)
Number of non-zeros.
Definition: matrix_imp.h:331
glucat::matrix::eig_genus::m_safe_arg
Scalar_T m_safe_arg
Argument such that exp(pi-m_safe_arg) lies between arguments of eigenvalues.
Definition: matrix.h:197
glucat::matrix::signed_perm_nork
const RHS_T signed_perm_nork(const LHS_T &lhs, const RHS_T &rhs)
Left inverse of Kronecker product where lhs is a signed permutation matrix.
Definition: matrix_imp.h:299
glucat
Definition: clifford_algebra.h:39
glucat::matrix::safe_eig_case
@ safe_eig_case
Definition: matrix.h:187
glucat::matrix::negative_eig_case
@ negative_eig_case
Definition: matrix.h:187
glucat::matrix::inner
Scalar_T inner(const LHS_T &lhs, const RHS_T &rhs)
Inner product: sum(x(i,j)*y(i,j))/x.nrows()
Definition: matrix_imp.h:453
glucat::matrix::both_eig_case
@ both_eig_case
Definition: matrix.h:187
glucat::matrix::eigenvalues
ublas::vector< std::complex< double > > eigenvalues(const Matrix_T &val)
Eigenvalues of a matrix.
Definition: matrix_imp.h:555
glucat::matrix::nork
const RHS_T nork(const LHS_T &lhs, const RHS_T &rhs, const bool mono=true)
Left inverse of Kronecker product.
Definition: matrix_imp.h:250
glucat::matrix::classify_eigenvalues
eig_genus< Matrix_T > classify_eigenvalues(const Matrix_T &val)
Classify the eigenvalues of a matrix.
Definition: matrix_imp.h:588
glucat::matrix::prod
const RHS_T::expression_type prod(const ublas::matrix_expression< LHS_T > &lhs, const ublas::matrix_expression< RHS_T > &rhs)
Product of matrices.
Definition: matrix_imp.h:435