Skip to content

Commit

Permalink
Updating Linear Algebra Modules & Sample, PyPI package and install, a…
Browse files Browse the repository at this point in the history
…nd CMake installation of source C++ project for Linux based operating systems
  • Loading branch information
akielaries committed Jan 8, 2023
1 parent 73e2e99 commit ba0dc01
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 22 deletions.
Binary file added linalg_ops
Binary file not shown.
57 changes: 35 additions & 22 deletions samples/cpp/linalg_ops.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* TESTING BASIC LINEAR ALGEBRA OPERATIONS
/*
* Linear Algebra Sample File
*
* test driver program on the implementations for some basic Linear Algebra
* operations.
*
Expand All @@ -10,43 +12,54 @@
#include <stdio.h>
#include <vector>
#include <cassert>
//#include <openMTPK/linalg.hpp>
#include "../../include/linalg/vectors.hpp"
#include "../../include/linalg/matrix.hpp"

#include <openMTPK/linalg.hpp>
//#include "../../include/linalg/vectors.hpp"
//#include "../../include/linalg/matrix.hpp"


int main() {
// declaring an object for the Vectors class is permitted
mtpk::Vectors v;
std::cout << "MATRIX/VECTOR OPERATIONS EXAMPLE" << std::endl;
std::cout << "MATRIX/VECTOR OPERATIONS EXAMPLE\n" << std::endl;

int x = v.add(1, 3);

std::cout << "Sum = " << x << std::endl;
std::cout << "Sum = " << x << "\n\n";

// declaring matrix with random negative floats
std::cout << "Creating 2x2 matrix (MAT1) of random negative floats\n";
auto matrix_neg = mtpk::mtx<float>::randn(2, 2);
matrix_neg.print_shape();
matrix_neg.print_mtx();

// declaring matrix with random positive floats
std::cout << "Creating 2x2 matrix (MAT1) of random positive floats\n";
auto matrix_pos = mtpk::mtx<float>::rand(2, 2);
matrix_pos.print_shape();
matrix_pos.print_mtx();

std::cout << "Multiply each element of the matrix(MAT1) by itself" << "\n";
(matrix_pos.scalar_mult(2.f)).print_mtx();

// declaring matrix with random floats
std::cout << "Creating 2x2 matrix of random floats" << "\n";
auto MAT1 = mtpk::mtx<float>::randn(2, 2);
MAT1.print_shape();
MAT1.print_mtx();

// declare a matrix of zeros with 3 x 5 dimensions
std::cout << "Creating 3x5 matrix of 0's" << "\n";
auto MAT2 = mtpk::Matrix<float>(3, 5);
MAT2.print_shape();
MAT2.print_mtx();
auto matrix_zero = mtpk::Matrix<float>(3, 5);
matrix_zero.print_shape();
matrix_zero.print_mtx();

// another method to declare a matrix of zeros with 8 x 9 dimensions
std::cout << "Creating 8x9 matrix of 0's" << "\n";
auto MAT3 = mtpk::mtx<int>::zeros(8, 9);
MAT3.print_shape();
MAT3.print_mtx();

// declare a matrix
// auto MAT4 = mtpk::Matrix<float>();
auto matrix_zero_2 = mtpk::mtx<int>::zeros(8, 9);
matrix_zero_2.print_shape();
matrix_zero_2.print_mtx();

// MAT4.print_shape();
// MAT4.print_mtx();
// declare matrix of ones with 8 x 9 dimensions
std::cout << "Creating 8x9 matrix of 1's" << "\n";
auto matrix_one = mtpk::mtx<int>::ones(8, 9);
matrix_one.print_shape();
matrix_one.print_mtx();

return 0;
}
Expand Down

0 comments on commit ba0dc01

Please sign in to comment.