15#include "tbci/basics.h"
16#include "tbci/vector.h"
18#include "tbci/matrix_sig.h"
25#if !defined(NO_GD) && !defined(AUTO_DECL)
26# include "tbci/matrix_gd.h"
32#ifdef HAVE_GCC295_FRIEND_BUG
34# define _ENDVEC getendvec()
37# define _COL columns()
41# define _ENDVEC endvec
49#ifndef TBCI_DISABLE_EXCEPT
57 :
NumErr(
"Error in Matrix library") {}
67# pragma interface "matrix.h"
72template <
typename T>
class Matrix;
73template <
typename T>
class TMatrix;
77template <
typename T>
class Tensor;
95#if defined(SMP) && !defined(SMP_MATSLICE)
96# define SMP_MATSLICE 4096
99# define SMP_MATSLICE2 (SMP_MATSLICE/sizeof(T))
162 explicit TMatrix (
const unsigned = 0);
164 TMatrix (
const unsigned,
const unsigned);
166 TMatrix (
const T&,
const unsigned,
const unsigned);
180 static const char*
mat_info () {
return (
"TMatrix"); }
187#ifndef HAVE_PROMOTION_BUG
188# ifndef HAVE_GCC295_TMPLFRNDCLS_BUG
190 template <
typename U>
friend class Matrix;
198 while (t <
endvec) *t++ = *u++; }
205 while (t <
endvec) *t++ = *u++; }
249 {
Matrix<T> m (*
this);
return (m * tv); }
251 {
Matrix<T> m (*
this);
return (m * tsv); }
254#ifndef HAVE_GCC295_FRIEND_BUG
274#ifndef TBCI_NEW_BRACKET
281 T&
setval(
const T& val,
const unsigned int r,
const unsigned int c)
282 {
return mat[r][
c] = val; }
284 {
return mat[r][
c]; }
287 typename tbci_traits<T>::const_refval_type
288 get (
const unsigned r,
const unsigned c)
const
289 {
return mat[r][
c]; }
290 T&
set (
const T& val,
const unsigned r,
const unsigned c)
291 {
return mat[r][
c] = val; }
292 const T&
getcref(
const unsigned r,
const unsigned c)
const
293 {
return mat[r][
c]; }
302 {
return !(*
this == m); }
305 {
Matrix<T> m (tm);
return (*
this == m); }
307 {
return !(*
this == tm); }
311 {
return !(*
this ==
ts); }
341 void set_row_indexed (
const Vector<T>&,
const unsigned int,
344 void set_row_indexed (
const Vector<T>&,
const unsigned int,
348 const unsigned int,
const unsigned int);
352 template <
unsigned long dim>
424 const unsigned int ROW =
row;
425 const unsigned int COL =
col;
535 BCHK(
dim !=
a.dim,
MatErr, Different sizes in assignment,
a.dim, *
this );
562 return this->
fill (val);
598 const unsigned int r,
const unsigned off)
610 const unsigned ROW =
row;
611 for (
REGISTER unsigned r = 0; r < ROW; ++r)
617 const unsigned int c,
const unsigned off)
621 const unsigned ROW = v.
dim;
622 for (
REGISTER unsigned r = 0; r < ROW; ++r)
629 const unsigned ROW =
row;
632 for (
REGISTER unsigned j = 0; j < ROW; ++j)
662 unsigned long dd =
dim;
663 dim = ((
unsigned long)r)*
c;
682 dim = ((
unsigned long)r)*
col;
711 unsigned long olddim =
dim;
755 dim = ((
unsigned long)r)*
c;
796 BCHK (nr >
row,
MatErr, cheapdownsize does not upsize, nr, *
this);
799 dim = ((
unsigned long)nr) *
col;
858 return (
ts.real_destroy(),
false);
867 ts.real_destroy ();
return false;
874 ts.real_destroy ();
return false;
877 ts.real_destroy ();
return true;
885 BCHK(
col !=
a.col,
MatErr, number of cols differ in op,
a.col, *
this );
893 BCHK(
col !=
a.col,
MatErr, number of cols differ in op,
a.col, *
this );
902 BCHK(
col !=
a.col,
MatErr, number of cols differ in op,
a.col, *
this );
904 a.real_destroy();
return *
this;
910 BCHK(
col !=
a.col,
MatErr, number of cols differ in op,
a.col, *
this );
912 a.real_destroy();
return *
this;
929 ts.real_destroy ();
return *
this;
937 ts.real_destroy ();
return *
this;
1002template <typename T>
1009template <typename T>
1017template <typename T>
1025template <typename T>
1033template <typename T>
1042template <typename T>
1049template <
typename T>
1053template <
typename T>
1060template <
typename T>
1064 for (
unsigned r = 0; r < this->row; ++r)
1065 for (
unsigned c = 0;
c < this->
col; ++
c)
1066 trm.
mat[
c][r] = this->mat[r][
c];
1072template <typename T>
1078template <
typename T>
1081 if (this->
col != this->row) {
1084 return this->
swap(transmat);
1087 for (
unsigned r = 1; r < this->row; ++r)
1088 for (
unsigned c = 0;
c < r; ++
c)
1089 SWAP(this->mat[r][
c], this->mat[
c][r]);
1101{
return tm.fabs (); }
1106{
return m.fabs (); }
1117template <
typename T>
1168 static const char*
mat_info () {
return (
"TSMatrix"); }
1183 fac = (
T)1;
mut =
true;
return *
this; }
1189#ifndef HAVE_GCC295_FRIEND_BUG
1204#ifndef HAVE_GCC295_FRIEND_BUG
1230template <
typename T>
1238template <
typename T>
1245 dim = 0;
mat = (
T**)0;
return;
1259template <
typename T>
1266 if (evl &&
fac != (
T)1) {
1279template <
typename T>
1294template <
typename T>
1302template <
typename T>
1311template <
typename T>
1318template <
typename T>
1326template <
typename T>
1334 tm = *
this; tm.
detach ();
1345template <
typename T>
1353 tm = *
this; tm.
detach ();
1364template <
typename T>
1372template <
typename T>
1382template <typename T>
1390template <typename T>
1399template <
typename T>
1406 for (
unsigned i=0;
i<
row;
i++) {
1407 for (
unsigned j=0; j<m.
col; j++) {
1408 tmp =
mat[
i][0] * m.
mat[0][j];
1410 tmp +=
mat[
i][l] * m.
mat[l][j];
1411 c.mat[
i][j] = tmp *
fac;
1417template <
typename T>
1424 for (
unsigned i=0;
i<
row;
i++) {
1425 for (
unsigned j=0; j<tm.
col; j++) {
1426 tmp =
mat[
i][0] * tm.
get(0,j);
1428 tmp +=
mat[
i][l] * tm.
get(l,j);
1429 c.mat[
i][j] = tmp *
fac;
1435template <
typename T>
1441 for (
unsigned r=0; r<
row; r++) {
1444 el +=
mat[r][
c] * v(
c);
1450template <
typename T>
1456 for (
unsigned r=0; r<
row; r++) {
1466template <
typename T>
1492template <
typename T>
1524template <typename T>
1526{
ts._FAC = f *
ts._FAC;
return ts; }
1529template <
typename T>
1542template <
typename T>
1553template <typename T>
1555{
return ts.fabs (); }
1573template <
typename T>
1593 Matrix (
const T& v,
const unsigned r,
const unsigned c)
1616#ifndef HAVE_PROMOTION_BUG
1618 template <
typename U>
1622 template <
typename U>
1630 typename tbci_traits<T>::const_refval_type
1650 {
return this->
resize (d, d); }
1723 {
return !(*
this == m); }
1726 {
Matrix<T> m (tm);
return (*
this == m); }
1728 {
return !(*
this == tm); }
1732 {
return !(*
this ==
ts); }
1758template <
typename T>
1762 SWAP(this->dim, m.
dim);
1763 SWAP(this->row, m.
row);
1765 unsigned int tcol = this->col; this->col = m.
col; m.
col = tcol;
1766 SWAP(this->mat, m.
mat);
1767 SWAP(this->vec, m.
vec); SWAP(this->endvec, m.
endvec);
1773template <
typename T>
1774inline typename tbci_traits<T>::const_refval_type
1779 return this->mat[
i][j];
1782template <
typename T>
1787 return this->mat[
i][j];
1790template <
typename T>
1800template <
typename T>
1803 for (
unsigned r=0; r<m.
row; r++)
1808 for (
unsigned c=0;
c<m.
col;
c++)
1809 os << m(r,
c) <<
" ";
1816template <
typename T>
1821 for (
unsigned i=0;
i<m.
row;
i++)
1830template <typename T>
1838template <typename T>
1841 return os << Matrix<T>(
ts);
1848template <
typename T>
1854template <
typename T>
1863template <
typename T>
1870template <
typename T>
1878template <
typename T>
1882template <
typename T>
1889template <
typename T>
1893 BCHK(this->dim !=
a.dim,
MatErr, Operator + on diff
size matrices,
a.dim, t);
1897template <
typename T>
1901 BCHK(this->dim !=
a.dim,
MatErr, Operator - on diff
size matrices,
a.dim, t);
1906template <
typename T>
1913template <
typename T>
1921template <
typename T>
1929template <
typename T>
1939#define COST_MATMAT_OLD(ra,ca,cb) (ra*cb*(COST_UNIT_STORE+COST_LOOP \
1940 +ca*(3*COST_UNIT_LOAD+COST_NU_LOAD+COST_MULT+COST_ADD+COST_LOOP)))
1941#define COST_MATMAT_NEW(ra,ca,cb) (ra*cb*COST_MEMSET+ra*ca*(2*COST_UNIT_LOAD+COST_LOOP \
1942 +cb*(3*COST_UNIT_LOAD+COST_UNIT_STORE+COST_ADD+COST_MULT+COST_LOOP)))
1943#ifdef OLD_MAT_MAT_MULT
1944# define COST_MATMAT(ra,ca,cb) COST_MATMAT_OLD(ra,ca,cb)
1946# define COST_MATMAT(ra,ca,cb) COST_MATMAT_NEW(ra,ca,cb)
1950INST(template <typename T>
class TMatrix friend void do_mat_mat_mult (
const unsigned,
const unsigned, \
1953#include
"matrix_kernels.h"
1955#
if defined(SMP) && !defined(NOSMP_MATVEC)
1957template <
typename T>
1958inline void job_mat_mat_mult (
struct thr_ctrl *tc)
1965template <
typename T>
1971 update_n_thr(n_thr);
1972#ifndef OLD_MAT_MAT_MULT
1977 do_mat_mat_mult<T> (0UL, this->row, &
c,
this, &
b);
1982 const unsigned long first = slice_offset(1, n_thr, this->row, (
T*)0);
1983 unsigned long st, en = first;
1985 for (
unsigned t = 0; t < n_thr-1; ++t) {
1986 st = en; en = slice_offset(t+2, n_thr, this->row, (
T*)0);
1988 st, en, &
c,
this, &
b, (
void*)0);
1991 do_mat_mat_mult<T> (0UL, first, &
c,
this, &
b);
1994 for (
unsigned s = 0; s < n_thr-1; ++s)
2002template <
typename T>
2006#ifndef OLD_MAT_MAT_MULT
2010 do_mat_mat_mult <T> (0, this->row, &
c,
this, &
b);
2015template <
typename T>
2021 for (
unsigned i=0;
i<this->row;
i++) {
2022 for (
unsigned j=0; j<
a.col; j++) {
2023 tmp = this->mat[
i][0] *
a.mat[0][j];
2024 for (
REGISTER unsigned l=1; l<this->col; l++)
2025 tmp += this->mat[
i][l] *
a.mat[l][j];
2026 c.mat[
i][j] = tmp *
a.fac;
2029 a.real_destroy ();
return c;
2033template <
typename T>
2040template <
typename T>
2048template <
typename T>
2055template <
typename T>
2063template <
typename T>
2068 if (
LIKELY(this->vec == m.
vec || this->dim == 0))
2076template <
typename T>
2079 if (
LIKELY(this->row !=
ts.row || this->col !=
ts.col))
2080 return (
ts.real_destroy(),
false);
2081 if (
LIKELY(this->dim == 0)) {
2088 ts.real_destroy ();
return false;
2095 ts.real_destroy ();
return false;
2098 ts.real_destroy ();
return true;
2101template <
typename T>
2106 do_vec_fabssqr_exact (this->dim, this->vec,
res);
2108 do_vec_fabssqr_quick (this->dim, this->vec,
res);
2112template <
typename T>
2127 return (*
this * cn);
2131#if defined(SMP) && !defined(NOSMP_MATVEC)
2133template <
typename T>
2141template <
typename T>
2150template <
typename T>
2156 update_n_thr(n_thr);
2165 const unsigned long first = slice_offset(1, n_thr, this->row, (
T*)0);
2166 unsigned long st, en = first;
2168 for (
unsigned t = 0; t < n_thr-1; ++t) {
2169 st = en; en = slice_offset(t+2, n_thr, this->row, (
T*)0);
2171 st, en, &tv,
this, &v, (
void*)0);
2177 for (
unsigned s = 0; s < n_thr-1; ++s)
2188 update_n_thr(n_thr);
2194 const unsigned long first = slice_offset(1, n_thr, this->col, (
T*)0);
2196 unsigned long st, en = first;
2197 for (
unsigned t = 0; t < n_thr-1; ++t) {
2201 st = en; en = slice_offset(t+2, n_thr, this->col, (
T*)0);
2203 st, en, &tv,
this, &v, (
void*)0);
2207 for (
unsigned s = 0; s < n_thr-1; ++s)
2215template <
typename T>
2237template <
typename T>
2247template <
typename T>
2260template <
typename T>
2264 for (
unsigned r = 0; r < this->row; r++)
2267 for (
unsigned c = 0;
c < this->col;
c++)
2268 this->
operator() (r,
c) *=
fac;
2273template <
typename T>
2277 for (
unsigned r = 0; r < this->row; r++)
2279 T fac = (
T)1.0 / v (r);
2280 for (
unsigned c = 0;
c < this->col;
c++)
2281 (*
this) (r,
c) *=
fac;
2286template <
typename T>
2290 for (
unsigned c = 0;
c < this->col;
c++)
2291 (*
this) (r,
c) *= f;
2295template <
typename T>
2301 for (
unsigned c = 0;
c < this->col;
c++)
2302 (*
this) (r,
c) *= f;
2309template <
typename T>
2320 Mat_Brack (
const TMatrix<T> &tm,
unsigned int ix) : tmat(tm), idx (ix) {}
2325 {
EXPCHK(j >= tmat.col,
MatErr, Idx2 out of range, j, tmat.mat[idx][0]);
2326 return tmat.mat[idx][j]; }
2328 {
EXPCHK(j >= tmat.col,
MatErr, Idx2 out of range, j, tmat.mat[idx][0]);
2329 return tmat.mat[idx][j]; }
2332template <
typename T>
2335 this->vec = mb.tmat.mat[mb.idx];
2336 this->dim = (
unsigned long)mb.tmat.col; this->
keep =
true;
2339template <
typename T>
2342 this->dim = (
unsigned long)mb.tmat.col;
2345 this->vec =
NEW (
T, this->dim);
2347 TBCICOPY (this->vec, mb.tmat.mat[mb.idx],
T, this->dim);
2351 this->dim = 0; this->vec = (
T*)0;
2353#ifndef TBCI_NEW_BRACKET
2354template <
typename T>
2361template <
typename T>
2378#if defined(__GNUC__) && __GNUC__ >= 5 && __GNUC__ < 8 && (defined(__x86_64__) || defined(__i386__))
2379# define NOFMA __attribute__((target("no-fma")))
2387template <
typename T>
2390 T (*
fn)(
const unsigned i1,
const unsigned i2,
void* par);
2395template <
typename T>
2399 const unsigned cols = mat->
columns();
2401 for (
unsigned r = firstrow; r < lastrow; ++r)
2403 (*mat)(r,
c) = fn.
fn(r,
c, par);
2407template <
typename T>
2416template <
typename T>
2420 const unsigned rows = mat.
rows();
2422 update_n_thr(n_thr);
2428 const unsigned long first = slice_offset(1, n_thr, rows, (
T*)0);
2429 unsigned long st, en = first;
2431 for (
unsigned t = 0; t < n_thr-1; ++t) {
2432 st = en; en = slice_offset(t+2, n_thr, rows, (
T*)0);
2434 st, en, &mat, (
void*)&fn, par, (
void*)0);
2440 for (
unsigned s = 0; s < n_thr-1; ++s)
2446template <
typename T>
2453#if defined(SMP) && defined(HAVE_LIBNUMA)
2454template <
typename T>
2460 const unsigned rows = m.
rows();
2472 const unsigned first = slice_offset(1, n_thr, rows, (
T*)0);
2473 unsigned long st, en = first;
2475 unsigned long res = 0;
2476 for (
unsigned t = 0; t < n_thr-1; ++t) {
2477 st = en; en = slice_offset(t+2, n_thr, rows, (
T*)0);
2489 for (
unsigned t = 0; t < n_thr-1; ++t) {
2499template <
typename T>
long int Vector< T > & index
#define BCHK(cond, exc, txt, ind, rtval)
#define LIKELY(expr)
branch prediction note that we sometimes on purpose mark the unlikely possibility likely and vice ver...
#define TBCICOMP(n, o, t, s)
#define TBCICLEAR(n, t, s)
#define EXPCHK(cond, exc, txt, ind, rtval)
#define NAMESPACE_CSTD_END
#define PREFETCH_R(addr, loc)
In case gcc does not yet support __builtin_prefetch(), we have handcoded assembly with gcc for a few ...
#define BCHKNR(cond, exc, txt, ind)
#define PREFETCH_W(addr, loc)
#define TBCIFILL(n, v, t, s)
#define TBCICOPY(n, o, t, s)
TVector< T > LU_solve(const BdMatrix< T > &lu, const Vector< T > &b)
Solve the equation Ax = b where A IS already LU decomposed.
TMatrix< T > LU_invert(const BdMatrix< T > &lu)
return the inverse Matrix for an already LU decomposed BdMatrix
TMatrix< T > lu_invert(BdMatrix< T > &mat)
return the inverse Matrix for a BdMatrix by doing an LU decomposition
provides basic Vector functionality but arithmetic operators (+=, - , *, /...).
The class BdMatrix is an implementation to store and do operations on sparse Matrices with a band str...
Implementation of fixed sized Vectors (template argument) which is favorable for small Vectors,...
const T & operator[](unsigned int j) const
MatErr(const char *t, const long i=0)
TVector< T > transMult(const Vector_Sig< T > &) const
Matrix< T > & fill(const Vector< T > &v)
friend BVector< T > &FRIEND_TBCI2__ bvfillm FGD(BVector< T > &, const Matrix< T > &m)
bool operator!=(const Matrix< T > &m) const
Matrix(const Matrix< T > &m)
copy, does a real copy, as TM(M) is invoked (not TM(TM))
Matrix< T > & resize(const Matrix< T > &m)
Matrix< T > & mult_rows(const Vector< T > &)
Elementwise ops.
Matrix(const TSMatrix< T > &ts)
tbci_traits< T >::const_refval_type operator()(const unsigned int, const unsigned int) const HOT
ro element access
Matrix< T > & resize(const T &v, const unsigned r, const unsigned c)
Matrix(const TMatrix< U > &tm)
T aligned_value_type TALIGN(MIN_ALIGN2)
Matrix(const Matrix< U > &m)
TMatrix< T > operator*(const Matrix< T > &) const
Matrix< T > & setunit(const T &f=(T) 1)
Matrix(const Vector< T > &v, const enum rowcolvec r=colvec)
Matrix< T > & operator-=(const Matrix< T > &a)
friend NOINST char FRIEND_TBCI2__ gaussj FGD(Matrix< T > &, Matrix< T > &)
TSMatrix< T > operator/(const T &) const
Matrix(const unsigned d=0)
Matrix< T > & operator+=(const Matrix< T > &a)
Matrix< T > & resize(const unsigned d)
Matrix< T > & operator*=(const T &a)
Matrix< T > & div_row(const T &, const unsigned)
Matrix(const T &v, const unsigned r, const unsigned c)
TMatrix< T > operator-() const
TMatrix< T > operator+(const Matrix< T > &) const
TVector< T > transMult(const Vector< T > &) const HOT
Matrix< T > & fill(const T &v=(T) 0)
static const char * mat_info()
Matrix< T > & operator/=(const T &a)
Matrix< T > & div_rows(const Vector< T > &)
Matrix(const TMatrix< T > &tm) HOT
alias
bool operator==(const Matrix< T > &m) const
Matrix< T > & mult_row(const T &, const unsigned)
Matrix< T > & operator=(const Matrix< T > &m)
Assignment, non-resizing.
Matrix< T > & resize(const unsigned r, const unsigned c)
Matrix(const unsigned r, const unsigned c)
TMatrix< T > & row_expand(const unsigned int r)
Set new numbers of rows to matrix (expansion only).
friend NOINST TMatrix< T > LU_invert FGD(const BdMatrix< T > &)
TMatrix(const Matrix< U > &m)
friend void FRIEND_TBCI2__ do_mat_vec_transmult_exact FGD(const unsigned start, const unsigned end, TVector< T > *res, const Matrix< T > *mat, const Vector< T > *vec) HOT
void set_col_partial(const Vector< T > &, const unsigned int, const unsigned int)
Fill partial column.
TVector< T > get_col(const unsigned int) const
Column vector.
friend class TSMatrix< T >
T aligned_value_type TALIGN(MIN_ALIGN2)
TMatrix< T > & operator-()
void real_destroy()
real destructor
const T & getcref(const unsigned r, const unsigned c) const
friend class TVector< T >
TSMatrix< T > operator*=(const T &)
friend NOINST TMatrix< T > lu_invert FGD(BdMatrix< T > &)
TMatrix< T > & fill(const T &=(T) 0)
Fill matrix.
TSMatrix< T > operator/(const T &)
TMatrix< T > & resize(const unsigned int, const unsigned int)
Resize Matrix, specifying rows and columns.
unsigned int rows() const
number of rows
TMatrix< T > & swap(TMatrix< T > &)
TMatrix< T > & operator-=(TMatrix< T >)
TMatrix< T > & clear()
Clear matrix (fill with 0).
T operator()(const unsigned int, const unsigned int) const HOT
Element access (desctructive for TMatrix!).
TMatrix< T > & resize(const unsigned int d)
Resize Matrix to square shape.
T & set(const T &val, const unsigned r, const unsigned c)
friend void FRIEND_TBCI2__ do_mat_tsv_mult FGD(const unsigned start, const unsigned end, TVector< T > *res, const Matrix< T > *mat, const TSVector< T > *tsv) HOT
void set_row(const Vector< T > &, const unsigned int)
Fill complete row.
TMatrix< T > & alias(const TMatrix< T > &m)
bool operator!=(const Matrix< T > &m)
TMatrix< T > & operator=(const Matrix< T > &) HOT
assignment, non-resizing
TMatrix< T > transposed_copy() const
Inefficient! Use transMult if possible.
tbci_traits< T >::const_refval_type get(const unsigned r, const unsigned c) const
get, set and getcref are used internally and not for public consumption
friend void FRIEND_TBCI2__ do_mat_vec_transmult FGD(const unsigned start, const unsigned end, TVector< T > *res, const Matrix< T > *mat, const Vector< T > *vec) HOT
double fabssqr() const
Sum over all squared elements.
TMatrix(const TMatrix< U > &tm)
TSMatrix< T > operator/=(const T &)
friend void FRIEND_TBCI2__ do_mat_vec_mult FGD(const unsigned start, const unsigned end, TVector< T > *res, const Matrix< T > *mat, const Vector< T > *vec) HOT
TSMatrix< T > operator*(const T &)
static const char * mat_info()
void mark_destroy() const
mark destructible
unsigned int columns() const
number of columns
Mat_Brack< T > operator[](const unsigned int i) const
TMatrix< T > & transpose()
TMatrix< T > & operator+=(TMatrix< T >)
arithmetics ...
TMatrix< T > & cheapdownsizerow(const unsigned)
Resize number of rows without actually freeing memory (efficiency).
T ** mat
C storage layout: mat[row][col].
friend class Mat_Brack< T >
T & setval(const unsigned r, const unsigned c)
T * getrowptr(const unsigned r)
void set_row_partial(const Vector< T > &, const unsigned int, const unsigned int)
Fill partial row.
TVector< T > get_row(const unsigned int) const
Row vector.
friend NOINST TMatrix< T > lu_solve FGD(BdMatrix< T > &, const Matrix< T > &)
friend NOINST TMatrix< T > LU_solve FGD(const BdMatrix< T > &, const Matrix< T > &)
const T * getrowptr(const unsigned r) const
Helpers for matvecmul.
TMatrix< T > & operator+(TMatrix< T >)
T & setval(const T &val, const unsigned int r, const unsigned int c)
unsigned long size() const
number of elements
void set_col(const Vector< T > &, const unsigned int)
Fill complete column.
bool operator==(const Matrix< T > &m)
Comparison.
TMatrix< T > & setunit(const T &=(T) 1)
Set to unit matrix (optionally scaled).
friend class TMatrix< T >
void detach(TMatrix< T > *=0)
TSMatrix(const Matrix< T > &m, const T &f=(T) 1)
TMatrix< T > operator+(const Matrix< T > &)
bool operator!=(const Matrix< T > &m)
TSMatrix(const TMatrix< T > &tm, const T &f=(T) 1)
TSMatrix< T > & eval(TMatrix< T > *=0)
bool operator==(const Matrix< T > &)
T aligned_value_type TALIGN(MIN_ALIGN2)
unsigned long size() const
TSMatrix< T > & operator*=(const T &f)
void clone(bool=false, TMatrix< T > *=0)
static const char * mat_info()
TSMatrix< T > & operator/=(const T &f)
TSMatrix< T > & operator*(const T &f)
TSMatrix< T > & operator=(const TSMatrix< T > &ts)
TSMatrix< T > & operator-()
T operator()(const unsigned int r, const unsigned int c) HOT
TSMatrix< T > & operator/(const T &f)
TSMatrix(const TSMatrix< T > &ts)
unsigned long size() const
Temporary Base Class Idiom: Class TVector is used for temporary variables.
tbci_traits< T >::const_refval_type get(const unsigned long i) const
unsigned long size() const
T & set(const T &val, const unsigned long i) const
TVector(const unsigned long d=0)
Tensor class including arithmetics.
Vector(const unsigned long d=0)
T(* fn)(const unsigned i1, const unsigned i2, void *par)
mat_fill_fn(T(*f)(const unsigned, const unsigned, void *))
double fabs(const TBCI__ cplx< T > &c)
NAMESPACE_END NAMESPACE_CSTD TBCI__ cplx< T > sqrt(const TBCI__ cplx< T > &z)
NAMESPACE_TBCI char gaussj(Matrix< T > &a, Matrix< T > &b)
F_TMatrix< double > lu_solve(const F_Matrix< double > &A, const F_Matrix< double > &B, int overwriteA=0)
#define TBCIDELETE(t, v, sz)
#define REALLOC(v, os, t, s)
STD__ ostream & operator<<(STD__ ostream &os, const Matrix< T > &m)
double fabssqr(const TMatrix< T > &tm)
TMatrix< T > transpose(const TMatrix< T > &tm)
STD__ istream & operator>>(STD__ istream &in, Matrix< T > &m)
int numa_optimize(const Matrix< T > &m, bool fault_in)
void job_fill_mat(struct thr_ctrl *tc)
void do_mat_tsv_mult(const unsigned start, const unsigned end, TVector< T > *res, const Matrix< T > *mat, const TSVector< T > *vec)
void par_fill(Matrix< T > &mat, mat_fill_fn< T > fn, void *par)
void do_mat_vec_mult(const unsigned start, const unsigned end, TVector< T > *res, const Matrix< T > *mat, const Vector< T > *vec)
void do_mat_vec_transmult(const unsigned start, const unsigned end, TVector< T > *res, const Matrix< T > *mat, const Vector< T > *vec)
BVector< T > & bvfillm(BVector< T > &bv, const Matrix< T > &m)
void job_mat_vec_transmult(struct thr_ctrl *tc)
int lu_decomp(Matrix< T > &) HOT
LU decomposes the TBCI::Matrix mat.
void do_fill_mat(const unsigned firstrow, const unsigned lastrow, Matrix< T > *mat, mat_fill_fn< T > fn, void *par)
void job_mat_vec_mult(struct thr_ctrl *tc)
const unsigned TMatrix< T > const Matrix< T > * a
const unsigned TMatrix< T > * res
void thread_start_off(const int thr_no, thr_job_t job, const unsigned long off, const unsigned long sz,...)
void thread_wait(const int thr_no, struct job_output *out)
struct thr_struct * threads
void(* thr_job_t)(struct thr_ctrl *)
Before the double inclusion guard on purpose!
unsigned int do_exactsum()
#define STD_SMP_TEMPLATE5(oper, dm, a1, a2, a3, a4, a5)
#define STD_SMP_TEMPLATE2V(oper, dm, a1, a2)
#define STD_SMP_TEMPLATE4V(oper, dm, a1, a2, a3, a4)
#define STD_SMP_TEMPLATE3VV(oper, dm, a1, a2, a3)
#define STD_SMP_TEMPLATE3VC(oper, dm, a1, a2, a3)
#define STD_SMP_TEMPLATE2C(oper, dm, a1, a2)
#define STD_SMP_TEMPLATE4C(oper, dm, a1, a2, a3, a4)