Giter Club home page Giter Club logo

matrix_tmp's Introduction

Statslabs::Matrix - The C++ Linear Algebra Library (in development)

The repository contains the Statslabs::Matrix C++ linear algebra library code. Statslabs::Matrix is the fundamental package of Statslabs for statistical computing in C++.

Overview

Statslabs::Matrix is the fundamental package of Statslabs for statistical computing in C++. The Statslabs::Matrix library code is based on the matrix design chapter in 'The C++ Programming Language (4th Edition)' and provides:

  • A Matrix Template: Construction and Assignment; Subscripting and Slicing
  • Matrix arithmetic operations: Scalar Operations; Additions; Multiplication
  • Matrix Implementation: slice; MatrixSlice; MatrixRef; Matrix List Initialization; Matrix Access; Zero-Dimensional Matrix
  • An interface to Intel(R) MKL BLAS operations which apply to the Matrix template

Prerequisites

CMake >= 3.6.0
Intel Math Kernel Library (Intel MKL)

Installation on Ubuntu / macOS

  1. Clone the repository.
    git clone [email protected]:statslabs/matrix.git
  2. Configure the project.
    cd matrix
    mkdir build && cd build
    cmake ..
    To build docs/examples/tests, configure matrix with the following cmake options:
    -DSLAB_INCLUDE_DOCS=ON
    -DSLAB_INCLUDE_EXAMPLES=ON
    -DSLAB_INCLUDE_TESTS=ON
  3. Compile and install the library.
    make
    make install

Example program

examples/demo.cc:

#include <iostream>
#include "slab/matrix.h"

using namespace std;
using namespace slab;

int main() {
  mat A = {
      {1, 2, 3},
      {4, 5, 6},
      {7, 8, 9}
  };

  mat B = {
      {1, 2, 3},
      {4, 5, 6},
      {7, 8, 9}
  };

  // Element-wise addition
  cout << "A + B = " << A + B << endl;

  // Element-wise subtraction
  cout << "A - B = " << A - B << endl;

  // Element-wise multiplication
  cout << "A * B = " << A * B << endl;

  // Element-wise division
  cout << "A / B = " << A / B << endl;

  // Matrix multiplication
  cout << "matmul(A, B) = " << matmul(A, B) << endl;

  return 0;
}

Integration of Matrix in your own project

To make the project simple enough, we will create a CMake project for demo.cc.

  1. Make a project folder.

    mkdir example && cd example
  2. Create demo.cc and CMakeLists.txt in the project folder where file CMakeLists.txt should look like:

    cmake_minimum_required(VERSION 3.0)
    project(example)
    set(CMAKE_CXX_STANDARD 11)
    add_executable(example demo.cc)
    
    find_package(Matrix REQUIRED)
    target_link_libraries(example Statslabs::Matrix)
  3. Perform a out-of-source build.

    mkdir build && cd build
    cmake ..
    make
  4. Run the program.

    ./example

matrix_tmp's People

Contributors

ypan1988 avatar statslabs avatar

Watchers

James Cloos avatar  avatar

Forkers

kmsmgsh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.