Language | Package | IDE | Complier | OS |
---|---|---|---|---|
c99++ | Armadillo-10.7.5 | Xcode 12 | clang-1200.0.32.21 | OS Cataline 10.15.7 |
分别添加 libblas.tbd
,libcblas
,Accelerate.framework
组件.
#include
#include "../armadillo-10.7.5/include/armadillo"
using namespace std;
using namespace arma;
int main(int argc, const char * argv[]) {
cout << "Armadillo version: " << arma_version::as_string() << endl;
// insert code here...
return 0;
}
mat A( 3, 3, fill::zeros );
mat A( 3, 3, fill::ones );
mat I( 3, 3, fill::eyes );
A.print("A:");
auto x = A.at(1,1);
A(1,1) = 4;
vec y1 = A.row(1);
vec x2 = A.col(2);
vec D = A.diag();
mat B = A.t();
mat B = inv(A);
auto t = trace(A);
auto d = det(A);
{ 10 x 1 + 10 x 2 + 10 x 3 + b = 30 100 x 1 + 10 x 2 + 10 x 3 + b = 60 10 x 1 + 100 x 2 + 10 x 3 + b = 70 10 x 1 + 10 x 2 + 100 x 3 + b = 65 \begin{cases} &10x_1+10x_2+10x_3+b &= 30\\ &100x_1+10x_2+10x_3+b &= 60\\ &10x_1+100x_2+10x_3+b &= 70\\ &10x_1+10x_2+100x_3+b &= 65 \\ \end{cases} ⎩⎪⎪⎪⎨⎪⎪⎪⎧10x1+10x2+10x3+b100x1+10x2+10x3+b10x1+100x2+10x3+b10x1+10x2+100x3+b=30=60=70=65
A = [ 10 10 10 1 100 10 10 1 10 100 10 1 10 10 100 1 ] X = [ x 1 x 2 x 3 b ] B = [ 30 60 70 65 ] A=\begin{bmatrix} 10&10&10 &1 \\ 100&10&10 &1 \\ 10&100&10 &1 \\ 10&10&100 &1 \end{bmatrix} \qquad\qquad X = \begin{bmatrix} x_1\\x_2\\x_3\\b \end{bmatrix} \qquad\qquad B = \begin{bmatrix} 30\\60\\70\\65 \end{bmatrix} A=⎣⎢⎢⎡1010010101010100101010101001111⎦⎥⎥⎤X=⎣⎢⎢⎡x1x2x3b⎦⎥⎥⎤B=⎣⎢⎢⎡30607065⎦⎥⎥⎤
mat A = { \
{ 10, 10, 10, 1 }, \
{ 100, 10, 10, 1 }, \
{ 10,100, 10, 1 }, \
{ 10, 10,100, 1 } \
};
vec B = { 30, 60, 75, 65 };
mat X = solve(A, B);
X.print("X:);
(未完待续…)