tmp
This commit is contained in:
parent
bf14ada539
commit
4f4b39cc4b
@ -29,13 +29,17 @@
|
|||||||
// To compile the code, use: g++ use_armadillo_ex.cpp -larmadillo
|
// To compile the code, use: g++ use_armadillo_ex.cpp -larmadillo
|
||||||
#define GCTL_USE_ARMADILLO
|
#define GCTL_USE_ARMADILLO
|
||||||
|
|
||||||
|
#include "gctl/core/array_algorithm.h"
|
||||||
|
#include "gctl/core/matrix_algorithm.h"
|
||||||
#include "gctl/core/armadillo_wrapper.h"
|
#include "gctl/core/armadillo_wrapper.h"
|
||||||
|
|
||||||
using namespace gctl;
|
using namespace gctl;
|
||||||
|
|
||||||
int main(int argc, char const *argv[])
|
int main(int argc, char const *argv[])
|
||||||
{
|
{
|
||||||
_1d_array a(10, 1, 0.5);
|
/*
|
||||||
|
_1d_array a(10);
|
||||||
|
sequence(a, 1.0, 0.5);
|
||||||
a.show();
|
a.show();
|
||||||
|
|
||||||
arma::Col<double> b;
|
arma::Col<double> b;
|
||||||
@ -54,7 +58,7 @@ int main(int argc, char const *argv[])
|
|||||||
a.show();
|
a.show();
|
||||||
|
|
||||||
matrix<double> m(10, 10);
|
matrix<double> m(10, 10);
|
||||||
m.random_float(1.0, 2.0, RdUniform);
|
random_float(m, 1.0, 2.0, RdUniform);
|
||||||
m.show();
|
m.show();
|
||||||
|
|
||||||
arma::Mat<double> amat;
|
arma::Mat<double> amat;
|
||||||
@ -66,5 +70,17 @@ int main(int argc, char const *argv[])
|
|||||||
_1d_array v;
|
_1d_array v;
|
||||||
armaCol2array(r, v);
|
armaCol2array(r, v);
|
||||||
v.show();
|
v.show();
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 定义系数矩阵 A 和常数向量 b
|
||||||
|
arma::mat A = { {2.0, 1.0}, {1.0, 3.0} };
|
||||||
|
arma::vec b = { {5.0, 6.0} };
|
||||||
|
|
||||||
|
// 求解线性方程组 Ax = b
|
||||||
|
arma::vec x = arma::solve(A, b, arma::solve_opts::fast);
|
||||||
|
|
||||||
|
_1d_array c;
|
||||||
|
armaCol2array(x, c);
|
||||||
|
c.show();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -29,13 +29,16 @@
|
|||||||
// To compile the code, use: g++ use_eigen_ex.cpp -I<path-to-eigen3>
|
// To compile the code, use: g++ use_eigen_ex.cpp -I<path-to-eigen3>
|
||||||
#define GCTL_USE_EIGEN3
|
#define GCTL_USE_EIGEN3
|
||||||
|
|
||||||
|
#include "gctl/core/array_algorithm.h"
|
||||||
|
#include "gctl/core/matrix_algorithm.h"
|
||||||
#include "gctl/core/eigen_wrapper.h"
|
#include "gctl/core/eigen_wrapper.h"
|
||||||
|
|
||||||
using namespace gctl;
|
using namespace gctl;
|
||||||
|
|
||||||
int main(int argc, char const *argv[])
|
int main(int argc, char const *argv[])
|
||||||
{
|
{
|
||||||
_1d_array a(10, 1, 0.5);
|
_1d_array a(10);
|
||||||
|
sequence(a, 1.0, 0.5);
|
||||||
a.show();
|
a.show();
|
||||||
|
|
||||||
Eigen::VectorXd b;
|
Eigen::VectorXd b;
|
||||||
@ -50,7 +53,7 @@ int main(int argc, char const *argv[])
|
|||||||
c.show();
|
c.show();
|
||||||
|
|
||||||
_2d_matrix m(5, 6);
|
_2d_matrix m(5, 6);
|
||||||
m.random_float(1, 2, RdUniform);
|
random_float(m, 1.0, 2.0, RdUniform);
|
||||||
m.show();
|
m.show();
|
||||||
|
|
||||||
Eigen::MatrixXd mat;
|
Eigen::MatrixXd mat;
|
||||||
|
Loading…
Reference in New Issue
Block a user