#ifndef MLPP_LIN_ALG_H #define MLPP_LIN_ALG_H // // LinAlg.hpp // // Created by Marc Melikyan on 1/8/21. // #include #include namespace MLPP { class LinAlg { public: // MATRIX FUNCTIONS std::vector> gramMatrix(std::vector> A); bool linearIndependenceChecker(std::vector> A); std::vector> gaussianNoise(int n, int m); std::vector> addition(std::vector> A, std::vector> B); std::vector> subtraction(std::vector> A, std::vector> B); std::vector> matmult(std::vector> A, std::vector> B); std::vector> hadamard_product(std::vector> A, std::vector> B); std::vector> kronecker_product(std::vector> A, std::vector> B); std::vector> elementWiseDivision(std::vector> A, std::vector> B); std::vector> transpose(std::vector> A); std::vector> scalarMultiply(double scalar, std::vector> A); std::vector> scalarAdd(double scalar, std::vector> A); std::vector> log(std::vector> A); std::vector> log10(std::vector> A); std::vector> exp(std::vector> A); std::vector> erf(std::vector> A); std::vector> exponentiate(std::vector> A, double p); std::vector> sqrt(std::vector> A); std::vector> cbrt(std::vector> A); std::vector> matrixPower(std::vector> A, int n); std::vector> abs(std::vector> A); double det(std::vector> A, int d); double trace(std::vector> A); std::vector> cofactor(std::vector> A, int n, int i, int j); std::vector> adjoint(std::vector> A); std::vector> inverse(std::vector> A); std::vector> pinverse(std::vector> A); std::vector> zeromat(int n, int m); std::vector> onemat(int n, int m); std::vector> full(int n, int m, int k); std::vector> sin(std::vector> A); std::vector> cos(std::vector> A); std::vector> rotate(std::vector> A, double theta, int axis = -1); std::vector> max(std::vector> A, std::vector> B); double max(std::vector> A); double min(std::vector> A); std::vector> round(std::vector> A); double norm_2(std::vector> A); std::vector> identity(double d); std::vector> cov(std::vector> A); std::tuple>, std::vector>> eig(std::vector> A); std::tuple>, std::vector>, std::vector>> SVD(std::vector> A); std::vector vectorProjection(std::vector a, std::vector b); std::vector> gramSchmidtProcess(std::vector> A); std::tuple>, std::vector>> QRD(std::vector> A); std::tuple>, std::vector>> chol(std::vector> A); double sum_elements(std::vector> A); std::vector flatten(std::vector> A); std::vector solve(std::vector> A, std::vector b); bool positiveDefiniteChecker(std::vector> A); bool negativeDefiniteChecker(std::vector> A); bool zeroEigenvalue(std::vector> A); void printMatrix(std::vector> A); // VECTOR FUNCTIONS std::vector> outerProduct(std::vector a, std::vector b); // This multiplies a, bT std::vector hadamard_product(std::vector a, std::vector b); std::vector elementWiseDivision(std::vector a, std::vector b); std::vector scalarMultiply(double scalar, std::vector a); std::vector scalarAdd(double scalar, std::vector a); std::vector addition(std::vector a, std::vector b); std::vector subtraction(std::vector a, std::vector b); std::vector subtractMatrixRows(std::vector a, std::vector> B); std::vector log(std::vector a); std::vector log10(std::vector a); std::vector exp(std::vector a); std::vector erf(std::vector a); std::vector exponentiate(std::vector a, double p); std::vector sqrt(std::vector a); std::vector cbrt(std::vector a); double dot(std::vector a, std::vector b); std::vector cross(std::vector a, std::vector b); std::vector abs(std::vector a); std::vector zerovec(int n); std::vector onevec(int n); std::vector> diag(std::vector a); std::vector full(int n, int k); std::vector sin(std::vector a); std::vector cos(std::vector a); std::vector max(std::vector a, std::vector b); double max(std::vector a); double min(std::vector a); std::vector round(std::vector a); double euclideanDistance(std::vector a, std::vector b); double norm_2(std::vector a); double norm_sq(std::vector a); double sum_elements(std::vector a); double cosineSimilarity(std::vector a, std::vector b); void printVector(std::vector a); // MATRIX-VECTOR FUNCTIONS std::vector> mat_vec_add(std::vector> A, std::vector b); std::vector mat_vec_mult(std::vector> A, std::vector b); // TENSOR FUNCTIONS std::vector>> addition(std::vector>> A, std::vector>> B); std::vector>> elementWiseDivision(std::vector>> A, std::vector>> B); std::vector>> sqrt(std::vector>> A); std::vector>> exponentiate(std::vector>> A, double p); std::vector> tensor_vec_mult(std::vector>> A, std::vector b); std::vector flatten(std::vector>> A); void printTensor(std::vector>> A); std::vector>> scalarMultiply(double scalar, std::vector>> A); std::vector>> scalarAdd(double scalar, std::vector>> A); std::vector>> resize(std::vector>> A, std::vector>> B); std::vector>> hadamard_product(std::vector>> A, std::vector>> B); std::vector>> max(std::vector>> A, std::vector>> B); std::vector>> abs(std::vector>> A); double norm_2(std::vector>> A); std::vector>> vector_wise_tensor_product(std::vector>> A, std::vector> B); private: }; } //namespace MLPP #endif /* LinAlg_hpp */