37 #include <visp3/core/vpArray2D.h>
38 #include <visp3/core/vpException.h>
59 template <
unsigned int>
61 unsigned int & ,
unsigned int & ,
unsigned int & )
66 unsigned int &Acols,
unsigned int &Brows,
unsigned int &Bcols)
76 unsigned int &Acols,
unsigned int &Brows,
unsigned int &Bcols)
85 unsigned int &Acols,
unsigned int &Brows,
unsigned int &Bcols)
94 unsigned int &Acols,
unsigned int &Brows,
unsigned int &Bcols)
104 unsigned int &Acols,
unsigned int &Brows,
unsigned int &Bcols)
114 unsigned int &Acols,
unsigned int &Brows,
unsigned int &Bcols)
124 unsigned int &Acols,
unsigned int &Brows,
unsigned int &Bcols)
134 unsigned int &Acols,
unsigned int &Brows,
unsigned int &Bcols)
142 template <
unsigned int>
143 inline void GEMM1(
const unsigned int & ,
const unsigned int & ,
const unsigned int & ,
149 inline void GEMM1<0>(
const unsigned int &Arows,
const unsigned int &Brows,
const unsigned int &Bcols,
152 for (
unsigned int r = 0; r < Arows; ++r)
153 for (
unsigned int c = 0; c < Bcols; ++c) {
155 for (
unsigned int n = 0; n < Brows; ++n)
156 sum += A[r][n] * B[n][c] * alpha;
162 inline void GEMM1<1>(
const unsigned int &Arows,
const unsigned int &Brows,
const unsigned int &Bcols,
165 for (
unsigned int r = 0; r < Arows; ++r)
166 for (
unsigned int c = 0; c < Bcols; ++c) {
168 for (
unsigned int n = 0; n < Brows; ++n)
169 sum += A[n][r] * B[n][c] * alpha;
175 inline void GEMM1<2>(
const unsigned int &Arows,
const unsigned int &Brows,
const unsigned int &Bcols,
178 for (
unsigned int r = 0; r < Arows; ++r)
179 for (
unsigned int c = 0; c < Bcols; ++c) {
181 for (
unsigned int n = 0; n < Brows; ++n)
182 sum += A[r][n] * B[c][n] * alpha;
188 inline void GEMM1<3>(
const unsigned int &Arows,
const unsigned int &Brows,
const unsigned int &Bcols,
191 for (
unsigned int r = 0; r < Arows; ++r)
192 for (
unsigned int c = 0; c < Bcols; ++c) {
194 for (
unsigned int n = 0; n < Brows; ++n)
195 sum += A[n][r] * B[c][n] * alpha;
200 template <
unsigned int>
201 inline void GEMM2(
const unsigned int & ,
const unsigned int & ,
const unsigned int & ,
207 inline void GEMM2<0>(
const unsigned int &Arows,
const unsigned int &Brows,
const unsigned int &Bcols,
211 for (
unsigned int r = 0; r < Arows; ++r)
212 for (
unsigned int c = 0; c < Bcols; ++c) {
214 for (
unsigned int n = 0; n < Brows; ++n)
215 sum += A[r][n] * B[n][c] * alpha;
216 D[r][c] = sum + C[r][c] * beta;
221 inline void GEMM2<1>(
const unsigned int &Arows,
const unsigned int &Brows,
const unsigned int &Bcols,
225 for (
unsigned int r = 0; r < Arows; ++r)
226 for (
unsigned int c = 0; c < Bcols; ++c) {
228 for (
unsigned int n = 0; n < Brows; ++n)
229 sum += A[n][r] * B[n][c] * alpha;
230 D[r][c] = sum + C[r][c] * beta;
235 inline void GEMM2<2>(
const unsigned int &Arows,
const unsigned int &Brows,
const unsigned int &Bcols,
239 for (
unsigned int r = 0; r < Arows; ++r)
240 for (
unsigned int c = 0; c < Bcols; ++c) {
242 for (
unsigned int n = 0; n < Brows; ++n)
243 sum += A[r][n] * B[c][n] * alpha;
244 D[r][c] = sum + C[r][c] * beta;
249 inline void GEMM2<3>(
const unsigned int &Arows,
const unsigned int &Brows,
const unsigned int &Bcols,
253 for (
unsigned int r = 0; r < Arows; ++r)
254 for (
unsigned int c = 0; c < Bcols; ++c) {
256 for (
unsigned int n = 0; n < Brows; ++n)
257 sum += A[n][r] * B[c][n] * alpha;
258 D[r][c] = sum + C[r][c] * beta;
263 inline void GEMM2<4>(
const unsigned int &Arows,
const unsigned int &Brows,
const unsigned int &Bcols,
267 for (
unsigned int r = 0; r < Arows; ++r)
268 for (
unsigned int c = 0; c < Bcols; ++c) {
270 for (
unsigned int n = 0; n < Brows; ++n)
271 sum += A[r][n] * B[n][c] * alpha;
272 D[r][c] = sum + C[c][r] * beta;
277 inline void GEMM2<5>(
const unsigned int &Arows,
const unsigned int &Brows,
const unsigned int &Bcols,
281 for (
unsigned int r = 0; r < Arows; ++r)
282 for (
unsigned int c = 0; c < Bcols; ++c) {
284 for (
unsigned int n = 0; n < Brows; ++n)
285 sum += A[n][r] * B[n][c] * alpha;
286 D[r][c] = sum + C[c][r] * beta;
291 inline void GEMM2<6>(
const unsigned int &Arows,
const unsigned int &Brows,
const unsigned int &Bcols,
295 for (
unsigned int r = 0; r < Arows; ++r)
296 for (
unsigned int c = 0; c < Bcols; ++c) {
298 for (
unsigned int n = 0; n < Brows; ++n)
299 sum += A[r][n] * B[c][n] * alpha;
300 D[r][c] = sum + C[c][r] * beta;
305 inline void GEMM2<7>(
const unsigned int &Arows,
const unsigned int &Brows,
const unsigned int &Bcols,
309 for (
unsigned int r = 0; r < Arows; ++r)
310 for (
unsigned int c = 0; c < Bcols; ++c) {
312 for (
unsigned int n = 0; n < Brows; ++n)
313 sum += A[n][r] * B[c][n] * alpha;
314 D[r][c] = sum + C[c][r] * beta;
318 template <
unsigned int T>
327 GEMMsize<T>(A, B, Arows, Acols, Brows, Bcols);
330 if ((Arows != D.getRows()) || (Bcols != D.getCols()))
331 D.resize(Arows, Bcols);
337 if (Acols != Brows) {
339 Acols, Brows, Bcols));
348 GEMM2<T>(Arows, Brows, Bcols, A, B, alpha, C, beta, D);
351 GEMM1<T>(Arows, Brows, Bcols, A, B, alpha, D);
393 vpTGEMM<0>(A, B, alpha, C, beta, D);
396 vpTGEMM<1>(A, B, alpha, C, beta, D);
399 vpTGEMM<2>(A, B, alpha, C, beta, D);
402 vpTGEMM<3>(A, B, alpha, C, beta, D);
405 vpTGEMM<4>(A, B, alpha, C, beta, D);
408 vpTGEMM<5>(A, B, alpha, C, beta, D);
411 vpTGEMM<6>(A, B, alpha, C, beta, D);
414 vpTGEMM<7>(A, B, alpha, C, beta, D);
unsigned int getCols() const
void vpGEMM(const vpArray2D< double > &A, const vpArray2D< double > &B, const double &alpha, const vpArray2D< double > &C, const double &beta, vpArray2D< double > &D, const unsigned int &ops=0)
unsigned int getRows() const
error that can be emitted by ViSP classes.
@ functionNotImplementedError
Function not implemented.
@ dimensionError
Bad dimension.