tmp
This commit is contained in:
parent
d4fa3ae6da
commit
f47df2ac6e
70
src/extra/use_armadillo_ex.cpp
Normal file
70
src/extra/use_armadillo_ex.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
/********************************************************
|
||||
* ██████╗ ██████╗████████╗██╗
|
||||
* ██╔════╝ ██╔════╝╚══██╔══╝██║
|
||||
* ██║ ███╗██║ ██║ ██║
|
||||
* ██║ ██║██║ ██║ ██║
|
||||
* ╚██████╔╝╚██████╗ ██║ ███████╗
|
||||
* ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
|
||||
* Geophysical Computational Tools & Library (GCTL)
|
||||
*
|
||||
* Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn)
|
||||
*
|
||||
* GCTL is distributed under a dual licensing scheme. You can redistribute
|
||||
* it and/or modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation, either version 2
|
||||
* of the License, or (at your option) any later version. You should have
|
||||
* received a copy of the GNU Lesser General Public License along with this
|
||||
* program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* If the terms and conditions of the LGPL v.2. would prevent you from using
|
||||
* the GCTL, please consider the option to obtain a commercial license for a
|
||||
* fee. These licenses are offered by the GCTL's original author. As a rule,
|
||||
* licenses are provided "as-is", unlimited in time for a one time fee. Please
|
||||
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
|
||||
* to include some description of your company and the realm of its activities.
|
||||
* Also add information on how to contact you by electronic and paper mail.
|
||||
******************************************************/
|
||||
|
||||
// Declare the marco to enable armadillo wrappers before include the head file.
|
||||
// To compile the code, use: g++ use_armadillo_ex.cpp -larmadillo
|
||||
#define GCTL_USE_ARMADILLO
|
||||
|
||||
#include "gctl/core/armadillo_wrapper.h"
|
||||
|
||||
using namespace gctl;
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
_1d_array a(10, 1, 0.5);
|
||||
a.show();
|
||||
|
||||
arma::Col<double> b;
|
||||
array2armaCol(a, b);
|
||||
std::cout << b;
|
||||
|
||||
_1d_array c;
|
||||
armaCol2array(b, c);
|
||||
c.show();
|
||||
|
||||
arma::Row<double> d;
|
||||
array2armaRow(c, d);
|
||||
std::cout << d;
|
||||
|
||||
armaRow2array(d, a);
|
||||
a.show();
|
||||
|
||||
matrix<double> m(10, 10);
|
||||
m.random_float(1.0, 2.0, RdUniform);
|
||||
m.show();
|
||||
|
||||
arma::Mat<double> amat;
|
||||
matrix2armaMat(m, amat);
|
||||
std::cout << amat;
|
||||
|
||||
arma::Col<double> r = amat*b;
|
||||
|
||||
_1d_array v;
|
||||
armaCol2array(r, v);
|
||||
v.show();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user