5 static bool rel_equal(REAL x, REAL y);
6 static bool rel_equal(REAL x, REAL y, REAL tol);
9 template <
class V1,
class V2>
10 static V2&
axpy(REAL alpha,
const V1& v1, V2& v2)
12 if (v1.size() != v2.size())
13 throw MissizeException();
15 CBLAS::axpy(v1.size(), v1.data(), v1.inc(), v2.data(), v2.inc());
20 template <
class M1,
class M2>
24 m2.resize(m1.columns(), m1.rows());
27 const unsigned LD1 = m1.leading_dim();
28 const unsigned LD2 = m2.leading_dim();
29 const REAL* d1 = m1.data();
33 for (
unsigned i=0, i1=0; i< m1.rows(); i++)
35 CBLAS::copy(m1.columns(), d1+i, LD1, d2+i1, 1);
43 template <
class T,
class U,
class V>
47 if (x.columns() != y.columns())
48 throw MissizeException();
51 z.resize(x.rows(), y.rows());
54 CBLAS::gemm(CblasNoTrans, CblasTrans, x.rows(), y.rows(), x.columns(), 1.0, x.data(), x.leading_dim(), y.data(), y.leading_dim(), 0.0, z.data(), z.leading_dim);
60 template <
class T,
class U,
class V>
61 static V&
mult(
const T& x,
const U& y, V& z)
64 if (x.columns() != y.rows())
65 throw MissizeException();
68 z.resize(x.rows(), y.columns());
73 CBLAS::gemm(CblasNoTrans, CblasNoTrans, x.rows(), y.columns(), x.columns(), 1.0, x.data(), x.leading_dim(), y.data(), y.leading_dim(), 0.0, z.data(), z.leading_dim);
76 CBLAS::gemv(CblasColMajor, CblasNoTrans, x.rows(), x.columns(), 1.0, x.data(), x.leading_dim(), y.data(), y.inc(), 0.0, z.data(), z.inc());
82 template <
class T,
class U,
class V>
86 if (x.rows() != y.rows())
87 throw MissizeException();
90 z.resize(x.columns(), y.columns());
93 CBLAS::gemm(CblasTrans, CblasNoTrans, x.columns(), y.columns(), x.rows(), 1.0, x.data(), x.leading_dim(), y.data(), y.leading_dim(), 0.0, z.data(), z.leading_dim);
99 template <
class T,
class U,
class V>
103 if (x.rows() != y.columns())
104 throw MissizeException();
107 z.resize(x.columns(), y.rows());
110 CBLAS::gemm(CblasTrans, CblasTrans, x.columns(), y.rows(), x.rows(), 1.0, x.data(), x.leading_dim(), y.data(), y.leading_dim(), 0.0, z.data(), z.leading_dim);
115 template <
class U,
class V,
class M>
116 static M& outer_prod(
const U& x,
const V& y, M& z)
119 if (x.columns() != 1 || y.columns() != 1)
120 throw MissizeException();
123 unsigned m = x.rows();
124 unsigned n = y.rows();
131 CBLAS::ger(CblasColMajor, m, n, x.data(), x.inc(), y.data(), y.inc(), z.data(), z.leading_dim());
static V & transpose_mult_transpose(const T &x, const U &y, V &z)
Multiples a matrix by a matrix or vector.
Definition: Ops.h:100
Class for general operations.
Definition: Ops.h:2
static V & transpose_mult(const T &x, const U &y, V &z)
Multiples the transpose of a matrix or vector by a matrix or vector.
Definition: Ops.h:83
static M2 & transpose(const M1 &m1, M2 &m2)
Does a transposition operation.
Definition: Ops.h:21
static V & mult(const T &x, const U &y, V &z)
Multiples a matrix by a matrix or vector.
Definition: Ops.h:61
static V & mult_transpose(const T &x, const U &y, V &z)
Multiples a matrix by the transpose of a matrix or vector.
Definition: Ops.h:44
static V2 & axpy(REAL alpha, const V1 &v1, V2 &v2)
Does a axpy operation.
Definition: Ops.h:10