Query re: cblas linking issue
Having a tough first time linking a cpp programme and making use of cblas for the first time.
I have obtained the 'libcblas.a' library and currently it is on desktop. I am running the following from the directory containing 'my_code.cpp' and 'cblas.h':
g++ c my_code.cpp
Followed by
g++ my_code.o L ~/Desktop lcblas
Which returns
/home/bob/Desktop/libcblas.a(cblas_dgemm.o): In function `cblas_dgemm':
cblas_dgemm.c:(.text+0xf3): undefined reference to `dgemm_'
cblas_dgemm.c:(.text+0x1d3): undefined reference to `dgemm_'
collect2: error: ld returned 1 exit status
I have also tried putting 'libcblas.a' in
/usr/local/lib
And running
g++ c my_code.cpp
Followed by
g++ my_code.o lcblas
Which returns
//usr/local/lib/libcblas.a(cblas_dgemm.o): In function `cblas_dgemm':
cblas_dgemm.c:(.text+0xf3): undefined reference to `dgemm_'
cblas_dgemm.c:(.text+0x1d3): undefined reference to `dgemm_'
collect2: error: ld returned 1 exit status
Really new to this all, appreciate any guidance.
See also questions close to this topic

What is the meaning of the using guard macro in struct definition
I have seen header file code something like this:
#ifndef GS #define GS struct GS gs { public: int n; gs(int n) : n{ n } {} }; #endif // !GS
What is the purpose of using
GS
instruct GS gs
? The code works exactly the same if I remove it.I am pretty new to C++. I tried to search this on google without success.

Defining return variable in the function declaration, is this legit in modern C++?
I am a big fan of CodeSignal(https://app.codesignal.com/) and I found really strange C++ grammar.
string r, longestDigitsPrefix(string s) { for(auto const c : s) { if(isdigit(c)) r += c; else break; } return r; }
Defining string r, in the function declaration, is this legit in modern c++? Above code, compiles and passes all the test in the CodeSignal console, but it produces compile error when I tried to compile locally. (std=c++14)
If this allow grammar in modern c++, which version does it comply with?

How to correctly copy Boost arrays in ROS callbacks?
I am relatively new to C++ (I am experienced in C and embedded C), some C++ concepts are still difficult to wrap my head around.
I am trying to copy boost array from a ROS callback. For those who are not familiar with ROS, the callback in my program (node) passes a reference to an object from the ROS messaging system.
The callback's declaration is:
void callback(const boost::shared_ptr<std_msgs::uint8_t>&);
Let's say I have two references that I want to copy from the callback, one of
bool foo
and another oneboost::array<uint8_t, 8UL> bar
.This is how I can copy the bool type:
bool x; void callback(const boost::shared_ptr<std_msgs::uint8_t>& msg) { x = msg>foo; }
This works fine, copies the value into another variable before the object is destructed.
Now, I am not familiar with Boost at all. Boost's array public construct/copy/destruct is this (reference):
template<typename U> array& operator=(const array<U, N>& other); Effects: std::copy(rhs.begin(),rhs.end(), begin())
Here's how I am trying to do to copy
bar
variable:boost::array<uint8_t, 8UL> y; void callback(const boost::shared_ptr<std_msgs::uint8_t>& msg) { std::copy(msg>data.begin(), msg>data.end() + 8, y.begin()); }
This again works fine, however is that the correct way of doing it? As far as I know
std::copy
function uses iterators, I don't exactly understand how this works (and if it's correct). I am familiar withmemcpy()
, could I use that instead, and if so, what would be the advantages? 
How to properly call the SGEMV in Fortran?
I want to perform a MatrixVector product in fortran using the SGEMV subroutine from BLAS. I have a code that is similar to this:
program test integer, parameter :: DP = selected_real_kind(15) real(kind=DP), dimension (3,3) :: A real(kind=DP), dimension (3) :: XP,YP call sgemv(A,XP,YP)
A is a 3x3 Matrix, XP and YP are Vectors. In the included module one can see the following code:
PURE SUBROUTINE SGEMV_F95(A,X,Y,ALPHA,BETA,TRANS) ! Fortran77 call: ! SGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY) USE F95_PRECISION, ONLY: WP => SP REAL(WP), INTENT(IN), OPTIONAL :: ALPHA REAL(WP), INTENT(IN), OPTIONAL :: BETA CHARACTER(LEN=1), INTENT(IN), OPTIONAL :: TRANS REAL(WP), INTENT(IN) :: A(:,:) REAL(WP), INTENT(IN) :: X(:) REAL(WP), INTENT(INOUT) :: Y(:) END SUBROUTINE SGEMV_F95
I understand that the some of the parameters are optional, so where am i wrong in the method call?

Use LAPACK and BLAS functions with mex file  MATLAB
I have written the following function in MATLAB and now I want to use mex API to modify my code using LAPACK and BLAS functions.
A = randn(20,20); b = randn(20,1); M = diag(diag(A)); C = A  M; [~,n] = size(C); v = eye(n); blk = 5; m1 = blk; p = n/m1; Is = eye(m1); %using blocks of dimensions n*blk=20*5 X = M \ b; Y = M \ C; for k = 1:p1 I = ((k1)*m1+1):k*m1'; X = X  Y(:,I) * (((Is + v(:,I)' * Y(:,I))) \ (v(:,I)' * X)); for j = k+1:p J = ((j1)*m1+1):j*m1; Y(:,J) = Y(:,J)  Y(:,I) * ((Is + v(:,I)' * Y(:,I)) \ (v(:,I)' * Y(:,J))); end end k = k+1; I = ((k1)*m1+1):k*m1; X = X  Y(:,I) * (((Is + v(:,I)' * Y(:,I))) \ (v(:,I)' * X))
Can anybody suggest me in what array calculations I can use LAPACK and BLAS functions to make the above calculations more efficient?

How do the leading dimension parameter for submatrices in cblas_dgemm() works?
I have three matrices A,B and C:
And the matrixmatrix product for general matrices:
void cblas_dgemm(const enum CBLAS_ORDER __Order, const enum CBLAS_TRANSPOSE __TransA, const enum CBLAS_TRANSPOSE __TransB, const int __M, const int __N, const int __K, const double __alpha, const double *__A, const int __lda, const double *__B, const int __ldb, const double __beta, double *__C, const int __ldc);
For using the
cblas_dgemm
command I need to know the leading dimension. For me it is clear that in the case of the total matrix A (or its transpose form) we have:M=5, N=4, lda=4
.In the case of submatrix C I think i have to overgive
&A[5]
and setM=3, N=2, ldc=4
But I have no idea how this could work in the case of red submatrix B with
M=4, N=2
. Can someone explain this to me. Thanks a lot. 
matrix vector product with banded matrix using cblas
I want to implement the following matrixvectorproduct:
float B[]= {5,1,2,0,0,0, 4,4,1,3,0,0, 0,5,3,2,2,0, 0,0,1,1,1,2, 0,0,0,1,2,2, 0,0,0,0,1,1}; //column major float v[]={1,2,1,1,2,1}; float w[6]={0}; int m=6; int n=6; int ku=1; kl=2; int ldb = 6; cblas_sgbmv(CblasColMajor, CblasNoTrans, m, n, kl, ku, 1.0, B, ldb,v,1, 1.0,w, 1);
 In the matrix B, I have one supdiagonal and two supdiagonals
 I saved the matrix B in CblasColMajor
My code does not give the result I want. I think I choose the wrong leading dimension. But how do I have to set it in the case of a banded matrix? I thought the leading dimension is relating to the original stored matrix.
Or is the meaning here that I have to work directly with a packed matrix?

Documentation of CBLAS procedures
(Note: I have seen: Any good documentation for the cblas interface?, but the link in the answer is dead and it seems not like an official documentation anyway.)
I've started looking at CBLAS and the surrounding libraries, because I would like to use them for matrix and vector multiplication. For example I found the following website a bit helpful, explaining some of the terms and libraries and it even shows with a little code how to do a multiplication and how to solve a linear equation system: https://www.seehuhn.de/pages/linear
However, the names of those procedures are so cryptic, that I don't have any clue, what they could stand for. I don't even know whether I should use the same procedures in different scenarios than the ones on that website, because the procedure name does not give me any hints. ("Can I use this procedure for all multiplications?" "When do I need to use something different?" "What are these arguments?") I think it's really badly named and feel like someone is playing a bad joke on me in terms of readability. Why no more descriptive names? (Note: On my system there is no "refblas" package I could install to read the files mentioned on the website.)
Nevertheless, I would like to understand how to use the thing.
I understand the different levels of operations apparently defined in the library. Level 1 vector operations, level 2 matrix vector, level 3 matrix matrix  this makes sense to me. However, this is not reflected in the names of these procedures either, afaics.
So my question is: Where can I see a comprehensive documentation containing an explanation what each of the procedures in the library does, what parameters it takes, best practices, etc., possibly with explanations also for the procedure names and their meaning? Maybe there are even some longer and more descriptive names, aliases for these procedures, but people don't use them?