a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
gslpp::matrix< double > Class Template Reference

A class for constructing and defining operations on real matrices. More...

#include <gslpp_matrix_double.h>

Detailed Description

template<>
class gslpp::matrix< double >

A class for constructing and defining operations on real matrices.

Author
HEPfit Collaboration

This class defines some common operations on real matrices using the GSL.

Definition at line 48 of file gslpp_matrix_double.h.

Public Member Functions

gsl_matrix & as_gsl_type ()
 
const gsl_matrix & as_gsl_type () const
 
gsl_matrix * as_gsl_type_ptr () const
 
void assign (const size_t &i, const size_t &j, const double &a)
 
void assign (const size_t &i, const size_t &j, const matrix< double > &a)
 
double determinant ()
 
void eigensystem (matrix< complex > &U, vector< complex > &S)
 
matrix< double > inverse ()
 
bool isSingular ()
 
 matrix (const gsl_matrix &m)
 
 matrix (const gsl_matrix *m)
 
 matrix (const matrix< double > &m)
 
 matrix (const size_t &size_i, const double &a)
 
 matrix (const size_t &size_i, const size_t &size_j, const double &a)
 
 matrix (const vector< double > &v)
 
bool operator!= (const matrix< double > &a) const
 
double & operator() (const size_t &i, const size_t &j)
 
double operator() (const size_t &i, const size_t &j) const
 
matrix< complexoperator* (const complex &z) const
 
matrix< double > operator* (const double &a) const
 
matrix< complexoperator* (const matrix< complex > &m) const
 
matrix< double > operator* (const matrix< double > &m) const
 
vector< complexoperator* (const vector< complex > &v) const
 
vector< double > operator* (const vector< double > &v) const
 
matrix< double > & operator*= (const double &a)
 
matrix< double > & operator*= (const matrix< double > &m)
 
matrix< complexoperator+ (const complex &z) const
 
matrix< double > operator+ (const double &a) const
 
matrix< double > operator+ (const matrix< double > &m) const
 
matrix< double > & operator+= (const double &a)
 
matrix< double > & operator+= (const matrix< double > &m)
 
matrix< double > operator- () const
 
matrix< complexoperator- (const complex &z) const
 
matrix< double > operator- (const double &a) const
 
matrix< double > operator- (const matrix< double > &m) const
 
matrix< double > & operator-= (const double &a)
 
matrix< double > & operator-= (const matrix< double > &m)
 
matrix< complexoperator/ (const complex &z) const
 
matrix< double > operator/ (const double &a) const
 
matrix< double > & operator/= (const double &a)
 
matrix< double > & operator= (const matrix< double > &m)
 
matrix< double > & operator= (double a)
 
bool operator== (const matrix< double > &a) const
 
void reset ()
 
size_t size () const
 
size_t size_i () const
 
size_t size_j () const
 
matrix< double > transpose () const
 
 ~matrix ()
 

Static Public Member Functions

static matrix< double > Id (size_t size)
 

Private Attributes

gsl_matrix * _matrix
 

Friends

std::ostream & operator<< (std::ostream &output, const matrix< double > &m)
 
Operations on matrix<double>
matrix< double > operator+ (const double &a, matrix< double > m)
 
matrix< double > operator- (const double &a, matrix< double > m)
 
matrix< double > operator* (const double &a, matrix< double > m)
 
vector< double > operator* (const vector< double > &v, matrix< double > m)
 
vector< complexoperator* (const vector< complex > &v, matrix< double > m)
 
matrix< complexoperator+ (const complex &z, matrix< double > m)
 
matrix< complexoperator- (const complex &z, matrix< double > m)
 
matrix< complexoperator* (const complex &z, matrix< double > m)
 

Constructor & Destructor Documentation

◆ matrix() [1/6]

gslpp::matrix< double >::matrix ( const size_t &  size_i,
const size_t &  size_j,
const double &  a 
)

Constructor

Constructor

Definition at line 24 of file gslpp_matrix_double.cpp.

25  {
26  _matrix = gsl_matrix_alloc(size_i, size_j);
27  gsl_matrix_set_all(_matrix, a);
28  }

◆ matrix() [2/6]

gslpp::matrix< double >::matrix ( const size_t &  size_i,
const double &  a 
)

Definition at line 30 of file gslpp_matrix_double.cpp.

31  {
32  _matrix = gsl_matrix_alloc(size_i, size_i);
33  gsl_matrix_set_all(_matrix, a);
34  }

◆ matrix() [3/6]

gslpp::matrix< double >::matrix ( const matrix< double > &  m)

Copy constructor

Copy constructor

Definition at line 37 of file gslpp_matrix_double.cpp.

38  {
39  _matrix = gsl_matrix_alloc(m.size_i(), m.size_j());
40  gsl_matrix_memcpy(_matrix, m.as_gsl_type_ptr());
41  }

◆ matrix() [4/6]

gslpp::matrix< double >::matrix ( const gsl_matrix< double > &  m)

Definition at line 43 of file gslpp_matrix_double.cpp.

44  {
45  _matrix = gsl_matrix_alloc(m.size1, m.size2);
46  gsl_matrix_memcpy(_matrix, &m);
47  }

◆ matrix() [5/6]

gslpp::matrix< double >::matrix ( const gsl_matrix< double > *  m)

Definition at line 49 of file gslpp_matrix_double.cpp.

50  {
51  _matrix = gsl_matrix_alloc(m->size1, m->size2);
52  gsl_matrix_memcpy(_matrix, m);
53  }

◆ matrix() [6/6]

gslpp::matrix< double >::matrix ( const vector< double > &  v)

Definition at line 55 of file gslpp_matrix_double.cpp.

56  {
57  size_t i, size = v.size();
58  _matrix = gsl_matrix_alloc(size, size);
59  gsl_matrix_set_all(_matrix, 0.);
60  for (i = 0; i < size; ++i)
61  gsl_matrix_set(_matrix, i, i, v(i));
62  }

◆ ~matrix()

gslpp::matrix< double >::~matrix ( )

Destructor

Definition at line 65 of file gslpp_matrix_double.cpp.

66  {
67  gsl_matrix_free(_matrix);
68  }

Member Function Documentation

◆ as_gsl_type() [1/2]

gsl_matrix & gslpp::matrix< double >::as_gsl_type ( )

Definition at line 300 of file gslpp_matrix_double.cpp.

301  {
302  return const_cast<gsl_matrix&> (*_matrix);
303  }

◆ as_gsl_type() [2/2]

const gsl_matrix & gslpp::matrix< double >::as_gsl_type ( ) const

Definition at line 305 of file gslpp_matrix_double.cpp.

306  {
307  return const_cast<gsl_matrix&> (*_matrix);
308  }

◆ as_gsl_type_ptr()

gsl_matrix * gslpp::matrix< double >::as_gsl_type_ptr ( ) const

Conversion

Definition at line 295 of file gslpp_matrix_double.cpp.

296  {
297  return _matrix;
298  }

◆ assign() [1/2]

void gslpp::matrix< double >::assign ( const size_t &  i,
const size_t &  j,
const double &  a 
)

Definition at line 108 of file gslpp_matrix_double.cpp.

109  {
110  gsl_matrix_set(_matrix, i, j, a);
111  }

◆ assign() [2/2]

void gslpp::matrix< double >::assign ( const size_t &  i,
const size_t &  j,
const matrix< double > &  a 
)

Assign submatrix

Definition at line 114 of file gslpp_matrix_double.cpp.

115  {
116  size_t ki, kj;
117  double *x;
118  if (i + a.size_i() <= size_i() && j + a.size_j() <= size_j())
119  for (ki = i; ki < i + a.size_i(); ki++)
120  for (kj = j; kj < j + a.size_j(); kj++)
121  {
122  x = gsl_matrix_ptr(_matrix, ki, kj);
123  *x = a(ki - i, kj - j);
124  } else
125  {
126  std::cout << "\n ** Wrong size assign in matrix<double> assign submatrix" << std::endl;
127  exit(EXIT_FAILURE);
128  }
129  }

◆ determinant()

double gslpp::matrix< double >::determinant ( )

Determinant matrix

Determinant of matrix

Definition at line 251 of file gslpp_matrix_double.cpp.

252  {
253 
254  matrix<double> m1(_matrix);
255  int signum;
256  gsl_permutation *p;
257 
258  if (size_j() != size_i())
259  {
260  std::cout << "\n ** Size mismatch in matrix<double> determinant" << std::endl;
261  exit(EXIT_FAILURE);
262  }
263 
264  if ((p = gsl_permutation_alloc(size_i())) == NULL)
265  {
266  std::cout << "\n ** Error in matrix<double> determinant" << std::endl;
267  exit(EXIT_FAILURE);
268  }
269 
270  if (gsl_linalg_LU_decomp(m1.as_gsl_type_ptr(), p, &signum))
271  {
272  std::cout << "\n ** Error in matrix<double> determinant" << std::endl;
273  gsl_permutation_free(p);
274  exit(EXIT_FAILURE);
275  }
276  gsl_permutation_free(p);
277  return gsl_linalg_LU_det(m1.as_gsl_type_ptr(), signum);
278  }

◆ eigensystem()

void gslpp::matrix< double >::eigensystem ( matrix< complex > &  U,
vector< complex > &  S 
)

Eigenvalues and eigenvectors

Definition at line 280 of file gslpp_matrix_double.cpp.

281  {
282  matrix<double> m(*this);
283 
284  gsl_eigen_nonsymmv_workspace *ws;
285 
286  ws = gsl_eigen_nonsymmv_alloc(size_i());
287 
288  gsl_eigen_nonsymmv(m.as_gsl_type_ptr(), S.as_gsl_type_ptr(),
289  U.as_gsl_type_ptr(), ws);
290 
291  gsl_eigen_nonsymmv_free(ws);
292  }

◆ Id()

matrix< double > gslpp::matrix< double >::Id ( size_t  size)
static

Identity matrix

Definition at line 154 of file gslpp_matrix_double.cpp.

155  {
156  matrix<double> m1(size, size, 0.);
157  if (gsl_matrix_add_diagonal(m1.as_gsl_type_ptr(), 1.))
158  {
159  std::cout << "\n Error in matrix<double> Id" << std::endl;
160  exit(EXIT_FAILURE);
161  }
162  return m1;
163  }

◆ inverse()

matrix< double > gslpp::matrix< double >::inverse ( )

Inverse matrix

Definition at line 178 of file gslpp_matrix_double.cpp.

179  {
180  matrix<double> m1(_matrix);
181  matrix<double> m2(_matrix);
182  int signum;
183  gsl_permutation *p;
184 
185  if (size_j() != size_i())
186  {
187  std::cout << "\n ** Size mismatch in matrix<double> inverse" << std::endl;
188  exit(EXIT_FAILURE);
189  }
190 
191  if ((p = gsl_permutation_alloc(size_i())) == NULL)
192  {
193  std::cout << "\n ** Error in matrix<double> inverse" << std::endl;
194  exit(EXIT_FAILURE);
195  }
196 
197  if (gsl_linalg_LU_decomp(m1.as_gsl_type_ptr(), p, &signum))
198  {
199  std::cout << "\n ** Error in matrix<double> inverse" << std::endl;
200  gsl_permutation_free(p);
201  exit(EXIT_FAILURE);
202  }
203 
204  if (gsl_linalg_LU_invert(m1.as_gsl_type_ptr(), p, m2.as_gsl_type_ptr()))
205  {
206  std::cout << "\n ** Error in matrix<double> inverse" << std::endl;
207  gsl_permutation_free(p);
208  exit(EXIT_FAILURE);
209  }
210  gsl_permutation_free(p);
211  return m2;
212  }

◆ isSingular()

bool gslpp::matrix< double >::isSingular ( )

Check is matrix is singular to avoid errors in lu.c

Check if matrix is singular (This is to avoid error checking by lu.c)

Definition at line 216 of file gslpp_matrix_double.cpp.

217  {
218  matrix<double> m1(_matrix);
219  int signum;
220  gsl_permutation *p;
221 
222  if (size_j() != size_i())
223  {
224  std::cout << "\n ** Size mismatch in bool isSingular" << std::endl;
225  exit(EXIT_FAILURE);
226  }
227 
228  if ((p = gsl_permutation_alloc(size_i())) == NULL)
229  {
230  std::cout << "\n ** Error in bool isSingular" << std::endl;
231  exit(EXIT_FAILURE);
232  }
233 
234  if (gsl_linalg_LU_decomp(m1.as_gsl_type_ptr(), p, &signum))
235  {
236  std::cout << "\n ** Error in bool isSingular" << std::endl;
237  gsl_permutation_free(p);
238  exit(EXIT_FAILURE);
239  }
240 
241  size_t i, n = m1.size_i();
242 
243  for (i = 0; i < n; i++) {
244  double u = gsl_matrix_get(m1.as_gsl_type_ptr(), i, i);
245  if (u == 0) return 1;
246  }
247  return 0;
248  }

◆ operator!=()

bool gslpp::matrix< double >::operator!= ( const matrix< double > &  a) const
inline

Definition at line 141 of file gslpp_matrix_double.h.

142  {
143  return(!(*this == a));
144  }

◆ operator()() [1/2]

double & gslpp::matrix< double >::operator() ( const size_t &  i,
const size_t &  j 
)

Set i-th element

Set element (i,j)

Definition at line 78 of file gslpp_matrix_double.cpp.

79  {
80  double *x = gsl_matrix_ptr(_matrix, i, j);
81  return *x;
82  }

◆ operator()() [2/2]

double gslpp::matrix< double >::operator() ( const size_t &  i,
const size_t &  j 
) const

Get element (i,j)

Definition at line 71 of file gslpp_matrix_double.cpp.

72  {
73  const double *x = gsl_matrix_const_ptr(_matrix, i, j);
74  return *x;
75  }

◆ operator*() [1/6]

matrix< complex > gslpp::matrix< double >::operator* ( const complex z) const

Multiplication operator (complex)

Definition at line 521 of file gslpp_matrix_double.cpp.

522  {
523  matrix<complex> v1(*this);
524  return v1*z;
525  }

◆ operator*() [2/6]

matrix< double > gslpp::matrix< double >::operator* ( const double &  a) const

Multiplication operator (double)

Definition at line 455 of file gslpp_matrix_double.cpp.

456  {
457  matrix<double> m1(_matrix);
458  if (gsl_matrix_scale(m1.as_gsl_type_ptr(), a))
459  {
460  std::cout << "\n Error in matrix<double> * (double)" << std::endl;
461  exit(EXIT_FAILURE);
462  }
463  return m1;
464  }

◆ operator*() [3/6]

matrix< complex > gslpp::matrix< double >::operator* ( const matrix< complex > &  m) const

Definition at line 370 of file gslpp_matrix_double.cpp.

371  {
372  matrix<complex> m1(*this);
373  return m1 * m;
374  }

◆ operator*() [4/6]

matrix< double > gslpp::matrix< double >::operator* ( const matrix< double > &  m) const

Product (matrix)

Multiplication operator (matrix)

Definition at line 351 of file gslpp_matrix_double.cpp.

352  {
353  unsigned int i, j, k;
354  matrix<double> m1(size_i(), m.size_i(), 0.);
355 
356  if (size_j() != m.size_i())
357  {
358  std::cout << "\n Error in matrix<double> *" << std::endl;
359  exit(EXIT_FAILURE);
360  }
361 
362  for (i = 0; i < size_i(); i++)
363  for (j = 0; j < m.size_j(); j++)
364  for (k = 0; k < m.size_i(); k++)
365  m1(i, j) += (*this)(i, k) * m(k, j);
366 
367  return m1;
368  }

◆ operator*() [5/6]

vector< complex > gslpp::matrix< double >::operator* ( const vector< complex > &  v) const

Multiplication (vector complex)

Multiplication assignment (vector complex)

Definition at line 398 of file gslpp_matrix_double.cpp.

399  {
400  matrix<complex> m1(*this);
401  return m1 * v;
402  }

◆ operator*() [6/6]

vector< double > gslpp::matrix< double >::operator* ( const vector< double > &  v) const

Multiplication (vector double)

Multiplication assignment (vector double)

Definition at line 377 of file gslpp_matrix_double.cpp.

378  {
379  vector<double> v1(size_i(), 0.);
380 
381  if (size_j() != v.size())
382  {
383  std::cout << "\n ** Size mismatch in matrix<double> * (vector double)"
384  << std::endl;
385  exit(EXIT_FAILURE);
386  }
387  if (gsl_blas_dgemv(CblasNoTrans, 1., _matrix, v.as_gsl_type_ptr(),
388  0., v1.as_gsl_type_ptr()))
389  {
390  std::cout << "\n ** Error in matrix<double> * (vector double)"
391  << std::endl;
392  exit(EXIT_FAILURE);
393  }
394  return v1;
395  }

◆ operator*=() [1/2]

matrix< double > & gslpp::matrix< double >::operator*= ( const double &  a)

Multiplication assignment (double)

Definition at line 493 of file gslpp_matrix_double.cpp.

494  {
495  *this = *this * a;
496  return *this;
497  }

◆ operator*=() [2/2]

matrix< double > & gslpp::matrix< double >::operator*= ( const matrix< double > &  m)

Multiplication assignment (matrix)

Definition at line 419 of file gslpp_matrix_double.cpp.

420  {
421  if (!((size_i() == size_j()) && (size_i() == m.size_i()) && (size_j() == m.size_j())))
422  {
423  std::cout << "\n Error in matrix<double> *= (matrix)" << std::endl;
424  exit(EXIT_FAILURE);
425  }
426  *this = *this * m;
427  return *this;
428  }

◆ operator+() [1/3]

matrix< complex > gslpp::matrix< double >::operator+ ( const complex z) const

Addition operator (complex)

Definition at line 507 of file gslpp_matrix_double.cpp.

508  {
509  matrix<complex> v1(*this);
510  return v1 + z;
511  }

◆ operator+() [2/3]

matrix< double > gslpp::matrix< double >::operator+ ( const double &  a) const

Addition operator (double)

Definition at line 431 of file gslpp_matrix_double.cpp.

432  {
433  matrix<double> m1(_matrix);
434  if (gsl_matrix_add_constant(m1.as_gsl_type_ptr(), a))
435  {
436  std::cout << "\n Error in matrix<double> + (double)" << std::endl;
437  exit(EXIT_FAILURE);
438  }
439  return m1;
440  }

◆ operator+() [3/3]

matrix< double > gslpp::matrix< double >::operator+ ( const matrix< double > &  m) const

Addition operator (matrix)

Definition at line 327 of file gslpp_matrix_double.cpp.

328  {
329  matrix<double> m1(_matrix);
330  if (gsl_matrix_add(m1.as_gsl_type_ptr(), m.as_gsl_type_ptr()))
331  {
332  std::cout << "\n Error in matrix<double> +" << std::endl;
333  exit(EXIT_FAILURE);
334  }
335  return m1;
336  }

◆ operator+=() [1/2]

matrix< double > & gslpp::matrix< double >::operator+= ( const double &  a)

Addition assignment (double)

Definition at line 479 of file gslpp_matrix_double.cpp.

480  {
481  *this = *this +a;
482  return *this;
483  }

◆ operator+=() [2/2]

matrix< double > & gslpp::matrix< double >::operator+= ( const matrix< double > &  m)

Addition assignment (matrix)

Definition at line 405 of file gslpp_matrix_double.cpp.

406  {
407  *this = *this +m;
408  return *this;
409  }

◆ operator-() [1/4]

matrix< double > gslpp::matrix< double >::operator- ( ) const

check whether two matrices are equal Unary minus (matrix)

Unary minus

Definition at line 315 of file gslpp_matrix_double.cpp.

316  {
317  matrix<double> m1(_matrix);
318  if (gsl_matrix_scale(m1.as_gsl_type_ptr(), -1.))
319  {
320  std::cout << "\n Error in matrix<double> unary -" << std::endl;
321  exit(EXIT_FAILURE);
322  }
323  return m1;
324  }

◆ operator-() [2/4]

matrix< complex > gslpp::matrix< double >::operator- ( const complex z) const

Subtraction assignment (complex)

Subtraction operator (complex)

Definition at line 514 of file gslpp_matrix_double.cpp.

515  {
516  matrix<complex> v1(*this);
517  return v1 - z;
518  }

◆ operator-() [3/4]

matrix< double > gslpp::matrix< double >::operator- ( const double &  a) const

Subtraction assignment (double)

Subtraction operator (double)

Definition at line 443 of file gslpp_matrix_double.cpp.

444  {
445  matrix<double> m1(_matrix);
446  if (gsl_matrix_add_constant(m1.as_gsl_type_ptr(), -a))
447  {
448  std::cout << "\n Error in matrix<double> - (double)" << std::endl;
449  exit(EXIT_FAILURE);
450  }
451  return m1;
452  }

◆ operator-() [4/4]

matrix< double > gslpp::matrix< double >::operator- ( const matrix< double > &  m) const

Subtraction operator (matrix)

Definition at line 339 of file gslpp_matrix_double.cpp.

340  {
341  matrix<double> m1(_matrix);
342  if (gsl_matrix_sub(m1.as_gsl_type_ptr(), m.as_gsl_type_ptr()))
343  {
344  std::cout << "\n Error in matrix<double> -" << std::endl;
345  exit(EXIT_FAILURE);
346  }
347  return m1;
348  }

◆ operator-=() [1/2]

matrix< double > & gslpp::matrix< double >::operator-= ( const double &  a)

Subtraction assignment (double)

Definition at line 486 of file gslpp_matrix_double.cpp.

487  {
488  *this = *this -a;
489  return *this;
490  }

◆ operator-=() [2/2]

matrix< double > & gslpp::matrix< double >::operator-= ( const matrix< double > &  m)

Subtraction assignment (matrix)

Definition at line 412 of file gslpp_matrix_double.cpp.

413  {
414  *this = *this -m;
415  return *this;
416  }

◆ operator/() [1/2]

matrix< complex > gslpp::matrix< double >::operator/ ( const complex z) const

Division operator (complex)

Definition at line 528 of file gslpp_matrix_double.cpp.

529  {
530  matrix<complex> v1(*this);
531  return v1 / z;
532  }

◆ operator/() [2/2]

matrix< double > gslpp::matrix< double >::operator/ ( const double &  a) const

Division operator (double)

Definition at line 467 of file gslpp_matrix_double.cpp.

468  {
469  matrix<double> m1(_matrix);
470  if (gsl_matrix_scale(m1.as_gsl_type_ptr(), 1. / a))
471  {
472  std::cout << "\n Error in matrix<double> / (double)" << std::endl;
473  exit(EXIT_FAILURE);
474  }
475  return m1;
476  }

◆ operator/=()

matrix< double > & gslpp::matrix< double >::operator/= ( const double &  a)

Division assignment (double)

Definition at line 500 of file gslpp_matrix_double.cpp.

501  {
502  *this = *this / a;
503  return *this;
504  }

◆ operator=() [1/2]

matrix< double > & gslpp::matrix< double >::operator= ( const matrix< double > &  m)

Definition at line 90 of file gslpp_matrix_double.cpp.

91  {
92  if (size_i() == m.size_i() && size_j() == m.size_j())
93  gsl_matrix_memcpy(_matrix, m.as_gsl_type_ptr());
94  else
95  {
96  std::cout << "\n ** Wrong size assign in matrix<complex> operator =" << std::endl;
97  exit(EXIT_FAILURE);
98  }
99  return *this;
100  }

◆ operator=() [2/2]

matrix< double > & gslpp::matrix< double >::operator= ( double  a)

Definition at line 102 of file gslpp_matrix_double.cpp.

103  {
104  gsl_matrix_set_all(_matrix, a);
105  return *this;
106  }

◆ operator==()

bool gslpp::matrix< double >::operator== ( const matrix< double > &  a) const

Comparison == (matrix)

Definition at line 535 of file gslpp_matrix_double.cpp.

536  {
537  if (a.size_i() != size_i() || a.size_j() != size_j())
538  {
539  std::cout << "\n Error in matrix<double>::operator== (matrix): cannot compare matrices of different size" << std::endl;
540  exit(EXIT_FAILURE);
541  }
542  for (size_t i = 0; i < size_i(); i++)
543  for (size_t j = 0; j < size_j(); j++)
544  if (a(i,j) != (*this)(i,j)) return (false);
545  return (true);
546  }

◆ reset()

void gslpp::matrix< double >::reset ( )

Assign

Definition at line 85 of file gslpp_matrix_double.cpp.

86  {
87  gsl_matrix_set_zero(_matrix);
88  }

◆ size()

size_t gslpp::matrix< double >::size ( ) const

Definition at line 142 of file gslpp_matrix_double.cpp.

143  {
144  if (_matrix->size1 == _matrix->size2)
145  return _matrix->size2;
146  else
147  {
148  std::cout << "\n ** Non square matrix" << std::endl;
149  exit(EXIT_FAILURE);
150  }
151  }

◆ size_i()

size_t gslpp::matrix< double >::size_i ( ) const

Get matrix size

Get matrx size

Definition at line 132 of file gslpp_matrix_double.cpp.

133  {
134  return _matrix->size1;
135  }

◆ size_j()

size_t gslpp::matrix< double >::size_j ( ) const

Definition at line 137 of file gslpp_matrix_double.cpp.

138  {
139  return _matrix->size2;
140  }

◆ transpose()

matrix< double > gslpp::matrix< double >::transpose ( ) const

Transpose matrix

Definition at line 166 of file gslpp_matrix_double.cpp.

167  {
168  matrix<double> m1(size_j(), size_i(), 0.);
169  if (gsl_matrix_transpose_memcpy(m1.as_gsl_type_ptr(), _matrix))
170  {
171  std::cout << "\n Error in matrix<double> transpose" << std::endl;
172  exit(EXIT_FAILURE);
173  }
174  return m1;
175  }

Friends And Related Function Documentation

◆ operator* [1/4]

matrix<complex> operator* ( const complex z,
matrix< double >  m 
)
friend

Multiply a complex number by a real matrix

Parameters
zComplex number
mReal matrix
Returns
\( a*m \)

Definition at line 598 of file gslpp_matrix_double.cpp.

599  {
600  return m*z;
601  }

◆ operator* [2/4]

matrix<double> operator* ( const double &  a,
matrix< double >  m 
)
friend

Multiply a real number by real matrix

Parameters
aReal number
mReal matrix
Returns
\( a*m \)

Definition at line 573 of file gslpp_matrix_double.cpp.

574  {
575  return m*a;
576  }

◆ operator* [3/4]

vector<complex> operator* ( const vector< complex > &  v,
matrix< double >  m 
)
friend

Multiply a complex vector by a real matrix

Parameters
vComplex vector
mReal matrix
Returns
\( v*m \)

Definition at line 583 of file gslpp_matrix_double.cpp.

584  {
585  return m.transpose() * v;
586  }

◆ operator* [4/4]

vector<double> operator* ( const vector< double > &  v,
matrix< double >  m 
)
friend

Multiply a real vector by a real matrix

Parameters
vReal vector
mReal matrix
Returns
\( v*m \)

Definition at line 578 of file gslpp_matrix_double.cpp.

579  {
580  return m.transpose() * v;
581  }

◆ operator+ [1/2]

matrix<complex> operator+ ( const complex z,
matrix< double >  m 
)
friend

Add a complex number to a real matrix

Parameters
zComplex number
mReal matrix
Returns
\( z + m \)

Definition at line 588 of file gslpp_matrix_double.cpp.

589  {
590  return m + z;
591  }

◆ operator+ [2/2]

matrix<double> operator+ ( const double &  a,
matrix< double >  m 
)
friend

Add a real number to a real vector

Parameters
aReal number
mReal vector
Returns
\( a + m \)

Definition at line 563 of file gslpp_matrix_double.cpp.

564  {
565  return m + a;
566  }

◆ operator- [1/2]

matrix<complex> operator- ( const complex z,
matrix< double >  m 
)
friend

Subtract a complex number from a real matrix

Parameters
zComplex number
mReal matrix
Returns
\( z - m \)

Definition at line 593 of file gslpp_matrix_double.cpp.

594  {
595  return -m + z;
596  }

◆ operator- [2/2]

matrix<double> operator- ( const double &  a,
matrix< double >  m 
)
friend

Subtract a real number from a real matrix

Parameters
aReal number
mReal matrix
Returns
\( a - m \)

Definition at line 568 of file gslpp_matrix_double.cpp.

569  {
570  return -m + a;
571  }

◆ operator<<

std::ostream& operator<< ( std::ostream &  output,
const matrix< double > &  m 
)
friend

friend functions

Definition at line 549 of file gslpp_matrix_double.cpp.

550  {
551  size_t i, j;
552  for (i = 0; i < m.size_i(); i++)
553  {
554  output << std::endl;
555  output << "\t(";
556  for (j = 0; j < m.size_j() - 1; j++)
557  output << m(i, j) << ",";
558  output << m(i, j) << ")";
559  }
560  return output;
561  }

Member Data Documentation

◆ _matrix

gsl_matrix* gslpp::matrix< double >::_matrix
private

Definition at line 50 of file gslpp_matrix_double.h.


The documentation for this class was generated from the following files:
gslpp::matrix< double >::_matrix
gsl_matrix * _matrix
Definition: gslpp_matrix_double.h:50
gslpp::matrix< double >::size
size_t size() const
Definition: gslpp_matrix_double.cpp:142
gslpp::matrix< double >::size_j
size_t size_j() const
Definition: gslpp_matrix_double.cpp:137
gslpp::matrix< double >::size_i
size_t size_i() const
Definition: gslpp_matrix_double.cpp:132
S
A class for the form factor in .
Definition: MVllObservables.h:1436