tmp
This commit is contained in:
parent
d1bf361e43
commit
b9cd25efbc
@ -70,6 +70,7 @@ endmacro()
|
||||
if(GCTL_FOUND)
|
||||
add_example(core array_ex ON OFF OFF OFF)
|
||||
add_example(core matrix_ex ON OFF OFF OFF)
|
||||
add_example(core linear_algebra_ex ON OFF OFF OFF)
|
||||
add_example(core autodiff_ex ON OFF OFF OFF)
|
||||
add_example(core ceemdan_ex ON OFF OFF OFF)
|
||||
add_example(core cliplot_ex ON OFF OFF OFF)
|
||||
|
77
src/core/linear_algebra_ex.cpp
Normal file
77
src/core/linear_algebra_ex.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
/********************************************************
|
||||
* ██████╗ ██████╗████████╗██╗
|
||||
* ██╔════╝ ██╔════╝╚══██╔══╝██║
|
||||
* ██║ ███╗██║ ██║ ██║
|
||||
* ██║ ██║██║ ██║ ██║
|
||||
* ╚██████╔╝╚██████╗ ██║ ███████╗
|
||||
* ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
|
||||
* 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.
|
||||
******************************************************/
|
||||
|
||||
#include "gctl/math/linear_algebra.h"
|
||||
|
||||
using namespace gctl;
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
_1d_array a(10, 1.0, 0.1);
|
||||
_1d_array b(10, 1.0);
|
||||
|
||||
_1d_array c(10);
|
||||
veccpy(c, a, 2.0);
|
||||
c.show();
|
||||
|
||||
vecadd(c, a, b, 1.0, 0.5);
|
||||
c.show();
|
||||
|
||||
vecdiff(c, a, b, 1.0, 0.5);
|
||||
c.show();
|
||||
|
||||
vecscale(c, 2.0);
|
||||
c.show();
|
||||
|
||||
vecapp(c, a, 2.0);
|
||||
c.show();
|
||||
|
||||
vecsub(c, a, 2.0);
|
||||
c.show();
|
||||
|
||||
std::cout << vecdot(a, b) << "\n";
|
||||
|
||||
_2d_matrix m(10, 10, 1.0);
|
||||
matvec(c, m, a);
|
||||
c.show();
|
||||
|
||||
/*
|
||||
int rows = 20000;
|
||||
int cols = 20000;
|
||||
_2d_matrix m(rows, cols, 1.0);
|
||||
_1d_array v(cols, 2.0);
|
||||
_1d_array r(rows);
|
||||
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
matvec(r, m, v);
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
|
||||
std::chrono::duration<double> duration = end - start;
|
||||
std::cout << "matvec execution time: " << duration.count() << " seconds" << std::endl;
|
||||
*/
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user