I have a large computational problem I am working on. To decrease the computation speed of a set of linear equations in a square matrix, I have made use of lapack
and blas
. To get the libraries on my laptop (Ubuntu 2020) I ran the following command
sudo apt-get install libblas-dev liblapack-dev
Then I linked the code at compile by entering the following
g++ main.cpp -llapack -lblas
However, the cluster I am working on does not seem to have both of the libraries installed. It is much slower on the cluster, but yet a better chip. It runs, so I think it has the lapack
libraries installed, but not blas
. I'd like to install both.
How would I build and compile the lapack
and blas
libraries with neither access to root nor apt-get
?
Here is a short script for testing.
#include <iostream>
#include <vector>
extern "C" void dgesv_( int *n, int *nrhs, double *a, int *lda, int *ipiv, double *b, int *lbd, int *info );
int main() {
int SIZE = 3;
int nrhs = 1; // one column in b
int lda = SIZE;
int ldb = SIZE;
std::vector<int> i_piv(SIZE, 0); // pivot column vector
int info;
std::vector<double> A(SIZE*SIZE, 0); // sq mat with 0's
A = {5, 2, 8, 9, 7, 2, 10, 3, 4};
std::vector<double> b(SIZE);
b = {22, 13, 17};
dgesv_( &SIZE, &nrhs, &*A.begin(), &lda, &*i_piv.begin(), &*b.begin(), &ldb, &info );
return 0;
}
I'd like to build this with
g++ main.cpp -L/path/to/lapack -L/path/to/blas -llapack -lblas
where the b matrix is replaced with the solution, and the solution is 1.71, 1.29, 0.18
(which is sort of arbitrary so I'm not providing the "print_matrix" function in the code to reduce clutter).
Thank you for your time.