SmallMatrix.h File Reference
#include "GeneralDefine.h"
#include "Logger.h"
#include "SmallVector.h"
#include "SmallMatrix_impl.h"

Go to the source code of this file.

Classes

class  SmallMatrix< numberOfRows, numberOfColumns >
 Data type for small dense matrix. More...
 

Functions

template<unsigned int numberOfRows, unsigned int numberOfColumns>
std::ostream & operator<< (std::ostream &os, const SmallMatrix< numberOfRows, numberOfColumns > &A)
 Writes nicely formatted entries of the Matrix A to the stream os. More...
 
template<unsigned int numberOfRows, unsigned int numberOfColumns>
SmallMatrix< numberOfRows, numberOfColumns > operator* (const Mdouble d, const SmallMatrix< numberOfRows, numberOfColumns > &mat)
 Multiplies a matrix with a Mdouble. More...
 
template<unsigned int numberOfRows, unsigned int numberOfColumns>
SmallVector< numberOfColumns > operator* (SmallVector< numberOfRows > &vec, SmallMatrix< numberOfRows, numberOfColumns > &mat)
 Multiplies a matrix with a vector. More...
 

Function Documentation

◆ operator*() [1/2]

template<unsigned int numberOfRows, unsigned int numberOfColumns>
SmallMatrix<numberOfRows, numberOfColumns> operator* ( const Mdouble  d,
const SmallMatrix< numberOfRows, numberOfColumns > &  mat 
)

Multiplies a matrix with a Mdouble.

381 {
382  return mat * d;
383 }

◆ operator*() [2/2]

template<unsigned int numberOfRows, unsigned int numberOfColumns>
SmallVector<numberOfColumns> operator* ( SmallVector< numberOfRows > &  vec,
SmallMatrix< numberOfRows, numberOfColumns > &  mat 
)

Multiplies a matrix with a vector.

358 {
359  if (numberOfColumns == 0)
360  {
361  logger(WARN, "Trying to multiply a vector with a matrix without any columns.");
363  }
364  int nr = numberOfRows;
365  int nc = numberOfColumns;
366 
367  int i_one = 1;
368  double d_one = 1.0;
369  double d_zero = 0.0;
370 
372 
373  logger(DEBUG, "Matrix size: % x % \n Vector size: %", nr, nc, vec.size());
374 
375  dgemv_("T", &nr, &nc, &d_one, mat.data(), &nr, vec.data(), &i_one, &d_zero, result.data(), &i_one);
376  return result;
377 }
LL< Log::DEBUG > DEBUG
Debug information.
Definition: Logger.cc:58
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
LL< Log::WARN > WARN
Warning log level.
Definition: Logger.cc:54
void dgemv_(const char *trans, int *m, int *n, double *alpha, double *A, int *LDA, double *x, int *incx, double *beta, double *y, int *incy)
This does matrix times vector and is from blas level 2.
Mdouble * data()
Definition: SmallMatrix.h:351
Definition: SmallVector.h:62
unsigned int size() const
Definition: SmallVector.h:233
const Mdouble * data() const
Definition: SmallVector.h:238

References SmallMatrix< numberOfRows, numberOfColumns >::data(), SmallVector< numberOfRows >::data(), DEBUG, dgemv_(), logger, SmallVector< numberOfRows >::size(), and WARN.

◆ operator<<()

template<unsigned int numberOfRows, unsigned int numberOfColumns>
std::ostream& operator<< ( std::ostream &  os,
const SmallMatrix< numberOfRows, numberOfColumns > &  A 
)

Writes nicely formatted entries of the Matrix A to the stream os.

369 {
370  for (unsigned int i = 0; i < numberOfRows; ++i)
371  {
372  os << A.getRow(i) << std::endl;
373  }
374  return os;
375 }
@ A
Definition: StatisticsVector.h:42
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References A, and constants::i.