Visual Servoing Platform  version 3.1.0
vpMatrix_mul.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * BLAS subroutines.
33  *
34  *****************************************************************************/
35 
36 #include <visp3/core/vpConfig.h>
37 #include <visp3/core/vpMatrix.h>
38 
39 #ifndef DOXYGEN_SHOULD_SKIP_THIS
40 
41 #if defined(VISP_HAVE_LAPACK) && !defined(VISP_HAVE_LAPACK_BUILT_IN)
42 typedef int integer;
43 
44 extern "C" void dgemm_(char *transa, char *transb, integer *M, integer *N, integer *K, double *alpha, double *a,
45  integer *lda, double *b, integer *ldb, double *beta, double *c, integer *ldc);
46 
47 extern "C" void dgemv_(char *trans, integer *M, integer *N, double *alpha, double *a, integer *lda, double *x,
48  integer *incx, double *beta, double *y, integer *incy);
49 
50 void vpMatrix::blas_dgemm(char trans_a, char trans_b, const int M_, const int N_, const int K_, double alpha,
51  double *a_data, const int lda_, double *b_data, const int ldb_, double beta, double *c_data,
52  const int ldc_)
53 {
54  integer M = (integer)M_, K = (integer)K_, N = (integer)N_;
55  integer lda = (integer)lda_, ldb = (integer)ldb_, ldc = (integer)ldc_;
56 
57  dgemm_(&trans_a, &trans_b, &M, &N, &K, &alpha, a_data, &lda, b_data, &ldb, &beta, c_data, &ldc);
58 }
59 
60 void vpMatrix::blas_dgemv(char trans, const int M_, const int N_, double alpha, double *a_data, const int lda_,
61  double *x_data, const int incx_, double beta, double *y_data, const int incy_)
62 {
63  integer M = (integer)M_, N = (integer)N_;
64  integer lda = (integer)lda_, incx = (integer)incx_, incy = (integer)incy_;
65 
66  dgemv_(&trans, &M, &N, &alpha, a_data, &lda, x_data, &incx, &beta, y_data, &incy);
67 }
68 
69 #else
70 // Work arround to avoid warning LNK4221: This object file does not define any
71 // previously undefined public symbols
72 void dummy_vpMatrix_blas(){};
73 #endif
74 
75 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS