glucat 0.12.0
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#include <vector>
39
40namespace glucat
41{
42 namespace ublas = boost::numeric::ublas;
43
44 namespace matrix
45 {
47 template< typename LHS_T, typename RHS_T >
48 auto
49 kron(const LHS_T& lhs, const RHS_T& rhs) -> const
50 RHS_T;
51
53 template< typename LHS_T, typename RHS_T >
54 auto
55 mono_kron(const LHS_T& lhs, const RHS_T& rhs) -> const
56 RHS_T;
57
59 template< typename LHS_T, typename RHS_T >
60 auto
61 nork(const LHS_T& lhs, const RHS_T& rhs, const bool mono = true) -> const
62 RHS_T;
63
65 template< typename LHS_T, typename RHS_T >
66 auto
67 signed_perm_nork(const LHS_T& lhs, const RHS_T& rhs) -> const
68 RHS_T;
69
71 template< typename Matrix_T >
72 auto
73 nnz(const Matrix_T& m) -> typename Matrix_T::size_type;
74
76 template< typename Matrix_T >
77 auto
78 isinf(const Matrix_T& m) -> bool;
79
81 template< typename Matrix_T >
82 auto
83 isnan(const Matrix_T& m) -> bool;
84
86 template< typename Matrix_T >
87 auto
88 unit(const typename Matrix_T::size_type n) -> const
89 Matrix_T;
90
92 template< typename LHS_T, typename RHS_T >
93 auto
94 mono_prod(const ublas::matrix_expression<LHS_T>& lhs,
95 const ublas::matrix_expression<RHS_T>& rhs) -> const
96 typename RHS_T::expression_type;
97
99 template< typename LHS_T, typename RHS_T >
100 auto
101 sparse_prod(const ublas::matrix_expression<LHS_T>& lhs,
102 const ublas::matrix_expression<RHS_T>& rhs) -> const
103 typename RHS_T::expression_type;
104
106 template< typename LHS_T, typename RHS_T >
107 auto
108 prod(const ublas::matrix_expression<LHS_T>& lhs,
109 const ublas::matrix_expression<RHS_T>& rhs) -> const
110 typename RHS_T::expression_type;
111
113 template< typename Scalar_T, typename LHS_T, typename RHS_T >
114 auto
115 inner(const LHS_T& lhs, const RHS_T& rhs) -> Scalar_T;
116
118 template< typename Matrix_T >
119 auto
120 norm_frob2(const Matrix_T& val) -> typename Matrix_T::value_type;
121
123 template< typename Matrix_T >
124 auto
125 trace(const Matrix_T& val) -> typename Matrix_T::value_type;
126
128 template< typename Matrix_T >
129 auto
130 eigenvalues(const Matrix_T& val) -> std::vector< std::complex<double> >;
131
133 using eig_case_t = enum {
134 safe_eigs,
135 neg_real_eigs,
136 both_eigs};
137
139 template< typename Matrix_T >
141 {
142 using Scalar_T = typename Matrix_T::value_type;
144 bool m_is_singular = false;
149 };
150
152 template< typename Matrix_T >
153 auto
154 classify_eigenvalues(const Matrix_T& val) -> eig_genus<Matrix_T>;
155 }
156}
157
158#endif // _GLUCAT_MATRIX_H
auto nork(const LHS_T &lhs, const RHS_T &rhs, const bool mono=true) -> const RHS_T
Left inverse of Kronecker product.
Definition: matrix_imp.h:182
auto inner(const LHS_T &lhs, const RHS_T &rhs) -> Scalar_T
Inner product: sum(x(i,j)*y(i,j))/x.nrows()
Definition: matrix_imp.h:373
auto signed_perm_nork(const LHS_T &lhs, const RHS_T &rhs) -> const RHS_T
Left inverse of Kronecker product where lhs is a signed permutation matrix.
Definition: matrix_imp.h:228
auto trace(const Matrix_T &val) -> typename Matrix_T::value_type
Matrix trace.
Definition: matrix_imp.h:416
auto isinf(const Matrix_T &m) -> bool
Infinite.
Definition: matrix_imp.h:275
auto nnz(const Matrix_T &m) -> typename Matrix_T::size_type
Number of non-zeros.
Definition: matrix_imp.h:258
auto mono_kron(const LHS_T &lhs, const RHS_T &rhs) -> const RHS_T
Sparse Kronecker tensor product of monomial matrices.
Definition: matrix_imp.h:119
auto eigenvalues(const Matrix_T &val) -> std::vector< std::complex< double > >
Eigenvalues of a matrix.
Definition: matrix_imp.h:500
enum { safe_eigs, neg_real_eigs, both_eigs} eig_case_t
Classification of eigenvalues of a matrix.
Definition: matrix.h:136
auto norm_frob2(const Matrix_T &val) -> typename Matrix_T::value_type
Square of Frobenius norm.
Definition: matrix_imp.h:395
auto classify_eigenvalues(const Matrix_T &val) -> eig_genus< Matrix_T >
Classify the eigenvalues of a matrix.
Definition: matrix_imp.h:548
auto prod(const ublas::matrix_expression< LHS_T > &lhs, const ublas::matrix_expression< RHS_T > &rhs) -> const typename RHS_T::expression_type
Product of matrices.
Definition: matrix_imp.h:361
auto kron(const LHS_T &lhs, const RHS_T &rhs) -> const RHS_T
Kronecker tensor product of matrices - as per Matlab kron.
Definition: matrix_imp.h:83
auto mono_prod(const ublas::matrix_expression< LHS_T > &lhs, const ublas::matrix_expression< RHS_T > &rhs) -> const typename RHS_T::expression_type
Product of monomial matrices.
Definition: matrix_imp.h:320
auto sparse_prod(const ublas::matrix_expression< LHS_T > &lhs, const ublas::matrix_expression< RHS_T > &rhs) -> const typename RHS_T::expression_type
Product of sparse matrices.
Definition: matrix_imp.h:350
auto unit(const typename Matrix_T::size_type n) -> const Matrix_T
Unit matrix - as per Matlab eye.
Definition: matrix_imp.h:310
auto isnan(const Matrix_T &m) -> bool
Not a Number.
Definition: matrix_imp.h:292
Structure containing classification of eigenvalues.
Definition: matrix.h:141
bool m_is_singular
Is the matrix singular?
Definition: matrix.h:144
typename Matrix_T::value_type Scalar_T
Definition: matrix.h:142
Scalar_T m_safe_arg
Argument such that exp(pi-m_safe_arg) lies between arguments of eigenvalues.
Definition: matrix.h:148
eig_case_t m_eig_case
What kind of eigenvalues does the matrix contain?
Definition: matrix.h:146