Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jagot/cxxblas


https://github.com/jagot/cxxblas

blas cblas lapack lapacke

Last synced: 6 days ago
JSON representation

Awesome Lists containing this project

README

        

#+TITLE: CXXBLAS
#+AUTHOR: Stefanos Carlström
#+EMAIL: [email protected]

* Introduction
C++ (header-only) templated wrappers around CBLAS/LAPACKE.

Tested with OpenBLAS on Linux and Accelerate on macOS.

* Example usage
scale.cpp:
#+BEGIN_SRC C++
#include "cxxblas.h"
#include
#include
#include

template
void pvec(const std::vector& v)
{
std::cout << "[";
for(const auto &e : v)
std::cout << e << " ";
std::cout << "]" << std::endl;
}

int main(int argc, char* argv[])
{
int n = 10;
std::vector> x(n, {0.0, 1.0});

pvec(x);

cxxblas::scale(5.0, x);

pvec(x);

return 0;
}
#+END_SRC

CMakeLists.txt:
#+BEGIN_SRC cmake
cmake_minimum_required(VERSION 3.6)
project(meff)

# Or wherever cxxblas cmake directory is to be found
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cxxblas/cmake")
include(CXXBLAS)

add_executable(scale scale.cpp)
target_link_libraries(scale ${CXXBLAS_LIBRARIES})
#+END_SRC

Output:
#+BEGIN_EXAMPLE
[(0,1) (0,1) (0,1) (0,1) (0,1) (0,1) (0,1) (0,1) (0,1) (0,1) ]
[(0,5) (0,5) (0,5) (0,5) (0,5) (0,5) (0,5) (0,5) (0,5) (0,5) ]
#+END_EXAMPLE