/usr/include/blitz/meta/matmat.h is in libblitz0-dev 1:0.10-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | // -*- C++ -*-
/***************************************************************************
* blitz/meta/matmat.h TinyMatrix matrix-matrix product metaprogram
*
* $Id$
*
* Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
*
* This file is a part of Blitz.
*
* Blitz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Blitz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
*
* Suggestions: blitz-devel@lists.sourceforge.net
* Bugs: blitz-support@lists.sourceforge.net
*
* For more information, please see the Blitz++ Home Page:
* https://sourceforge.net/projects/blitz/
*
***************************************************************************/
#ifndef BZ_META_MATMAT_H
#define BZ_META_MATMAT_H
#ifndef BZ_TINYMAT_H
#error <blitz/meta/matmat.h> must be included via <blitz/tinymat.h>
#endif
#include <blitz/meta/metaprog.h>
#include <blitz/tinymatexpr.h>
BZ_NAMESPACE(blitz)
// Template metaprogram for matrix-matrix multiplication
template<int N_rows1, int N_columns, int N_columns2, int N_rowStride1,
int N_colStride1, int N_rowStride2, int N_colStride2, int K>
class _bz_meta_matrixMatrixProduct {
public:
static const int go = (K != N_columns - 1) ? 1 : 0;
template<typename T_numtype1, typename T_numtype2>
static inline BZ_PROMOTE(T_numtype1, T_numtype2)
f(const T_numtype1* matrix1, const T_numtype2* matrix2, int i, int j)
{
return matrix1[i * N_rowStride1 + K * N_colStride1]
* matrix2[K * N_rowStride2 + j * N_colStride2]
+ _bz_meta_matrixMatrixProduct<N_rows1 * go, N_columns * go,
N_columns2 * go, N_rowStride1 * go, N_colStride1 * go,
N_rowStride2 * go, N_colStride2 * go, (K+1) * go>
::f(matrix1, matrix2, i, j);
}
};
template<>
class _bz_meta_matrixMatrixProduct<0,0,0,0,0,0,0,0> {
public:
static inline _bz_meta_nullOperand f(const void*, const void*, int, int)
{ return _bz_meta_nullOperand(); }
};
template<typename T_numtype1, typename T_numtype2, int N_rows1, int N_columns,
int N_columns2, int N_rowStride1, int N_colStride1,
int N_rowStride2, int N_colStride2>
class _bz_tinyMatrixMatrixProduct {
public:
typedef BZ_PROMOTE(T_numtype1, T_numtype2) T_numtype;
static const int rows = N_rows1, columns = N_columns2;
_bz_tinyMatrixMatrixProduct(const T_numtype1* matrix1,
const T_numtype2* matrix2)
: matrix1_(matrix1), matrix2_(matrix2)
{ }
_bz_tinyMatrixMatrixProduct(const _bz_tinyMatrixMatrixProduct<T_numtype1,
T_numtype2, N_rows1, N_columns, N_columns2, N_rowStride1, N_colStride1,
N_rowStride2, N_colStride2>& x)
: matrix1_(x.matrix1_), matrix2_(x.matrix2_)
{ }
const T_numtype1* matrix1() const
{ return matrix1_; }
const T_numtype2* matrix2() const
{ return matrix2_; }
T_numtype operator()(int i, int j) const
{
return _bz_meta_matrixMatrixProduct<N_rows1, N_columns,
N_columns2, N_rowStride1, N_colStride1, N_rowStride2,
N_colStride2, 0>::f(matrix1_, matrix2_, i, j);
}
protected:
const T_numtype1* matrix1_;
const T_numtype2* matrix2_;
};
template<typename T_numtype1, typename T_numtype2, int N_rows1, int N_columns1,
int N_columns2>
inline
_bz_tinyMatExpr<_bz_tinyMatrixMatrixProduct<T_numtype1, T_numtype2, N_rows1,
N_columns1, N_columns2, N_columns1, 1, N_columns2, 1> >
product(const TinyMatrix<T_numtype1, N_rows1, N_columns1>& a,
const TinyMatrix<T_numtype2, N_columns1, N_columns2>& b)
{
typedef _bz_tinyMatrixMatrixProduct<T_numtype1, T_numtype2,
N_rows1, N_columns1, N_columns2, N_columns1, 1, N_columns2, 1> T_expr;
return _bz_tinyMatExpr<T_expr>(T_expr(a.data(), b.data()));
}
BZ_NAMESPACE_END
#endif // BZ_META_MATMAT_H
|