-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmatlab.h
84 lines (72 loc) · 2.07 KB
/
matlab.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#pragma once
#include "mymatrix.h"
#include <vector>
#include <tuple>
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <functional>
#include <ppl.h>
namespace Matlab{
/*
Element-wise Operations
*/
Matrix abs(const Matrix&);
Matrix log(const Matrix&);
Matrix exp(const Matrix&);
Matrix square(const Matrix&);
Matrix power(const Matrix&, double);
Matrix sqrt(const Matrix&);
std::vector<double> _exact_multiply(const Matrix & left, const Matrix & right);
Matrix _one_multiply_many(const Matrix & left, const Matrix & right);
Matrix multiply(const Matrix&, const Matrix&);
Matrix plus(const Matrix&, const Matrix&);
Matrix minus(const Matrix&, const Matrix&);
Matrix divide(const Matrix&, const Matrix&);
bool isPositive(const Matrix&);
double dotProduct(const Matrix&, const Matrix&);
/*
Statistic Operations
*/
Matrix max(const Matrix&, int);
double max(const Matrix&);
Matrix min(const Matrix&, int);
double min(const Matrix&);
Matrix median(const Matrix&, int);
double mean(const Matrix&);
Matrix mean(const Matrix&, int);
double var(const Matrix&);
Matrix var(const Matrix&, int);
// standard error
double stdDev(const Matrix&);
Matrix stdDev(const Matrix&, int);
// covariance matrix
Matrix covar(const Matrix&);
/*
Linear Algebra
*/
double norm1(const Matrix&);
double norm2(const Matrix&);
double FrobeniusNorm(const Matrix&);
// Solve matrix equation
Matrix solve(const Matrix&, const Matrix&);
Matrix _solve_iterative(const Matrix&, const Matrix&, int);
Matrix solve_Jacobi_iterative(const Matrix&, const Matrix&);
Matrix solve_Gauss_Seidel_iterative(const Matrix&, const Matrix&);
Matrix concatenate(const Matrix&, const Matrix&, int);
// Inverse Matrix: Gauss-Jordon
Matrix inverseGJ(const Matrix&);
// Eigen decomposition
std::tuple<Matrix> eigenDecompose(const Matrix&);
// Singular value decomposition
std::tuple<Matrix> SVD(const Matrix&);
// MP-Inverse
Matrix pseudoInverse(const Matrix&);
/*
File I/O
*/
Matrix read(const char*);
void write(const Matrix&, const char*);
}