tmp
This commit is contained in:
parent
93b125cbd5
commit
7bd7a8a09b
@ -38,57 +38,28 @@ double get_x(const point3dc &p)
|
|||||||
int main(int argc, char const *argv[]) try
|
int main(int argc, char const *argv[]) try
|
||||||
{
|
{
|
||||||
// create a new array and give initial values
|
// create a new array and give initial values
|
||||||
array<double> A(10, 0.0, 1.0);
|
array<double> a(10, 1.0);
|
||||||
A.memory_usage();
|
array<double> b(10, 2.0);
|
||||||
|
a.show();
|
||||||
|
std::cout << b << "\n";
|
||||||
|
|
||||||
A.log2linear(2);
|
if (a != b) std::cout << "a != b\n";
|
||||||
A.show();
|
|
||||||
|
|
||||||
A.linear2log(2);
|
array<double> c;
|
||||||
A.show();
|
c = a + b; c.show();
|
||||||
|
c = a - b; c.show();
|
||||||
|
c = b - a; c.show();
|
||||||
|
c = a * b; c.show();
|
||||||
|
c = a / b; c.show();
|
||||||
|
c = b / a; c.show();
|
||||||
|
|
||||||
A.for_each([](double &a){a += 1;});
|
double s = 3.0;
|
||||||
A.show();
|
c = a + s; c.show();
|
||||||
|
c = a - s; c.show();
|
||||||
A.sequence(1.0, 0.5, 3, 4, 1);
|
c = s - a; c.show();
|
||||||
A.show();
|
c = a * s; c.show();
|
||||||
|
c = a / s; c.show();
|
||||||
// copy A to a new array
|
c = s / a; c.show();
|
||||||
array<double> B = A;
|
|
||||||
B.normalize();
|
|
||||||
B.show();
|
|
||||||
|
|
||||||
array<double> S = A + B;
|
|
||||||
std::cout << "B + A = ";
|
|
||||||
S.show();
|
|
||||||
|
|
||||||
S.normalize();
|
|
||||||
S.show();
|
|
||||||
|
|
||||||
array<point3dc> P(5);
|
|
||||||
P.sequence(point3dc(0, 0, 0), point3dc(2, 1, 0.5));
|
|
||||||
P.show(std::cout, '\n');
|
|
||||||
|
|
||||||
//array<double> Px = P.extract<double>([](const point3dc &p)->double{return p.x;});
|
|
||||||
array<double> Px = P.extract<double>(get_x);
|
|
||||||
Px.show();
|
|
||||||
|
|
||||||
// create a new 2D array
|
|
||||||
matrix<int> C(5, 5, 1);
|
|
||||||
C.sequence(0, 1, 10);
|
|
||||||
|
|
||||||
std::cout << "C = \n";
|
|
||||||
C.show();
|
|
||||||
|
|
||||||
// save array to a binary file
|
|
||||||
save_matrix2binary("tmp/array_ex_out", C, "Int");
|
|
||||||
|
|
||||||
// import 2D array to a new object
|
|
||||||
matrix<int> D;
|
|
||||||
read_binary2matrix("tmp/array_ex_out", D);
|
|
||||||
|
|
||||||
std::cout << "D = \n";
|
|
||||||
D.show();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
|
@ -128,7 +128,8 @@ int main(int argc, char const *argv[]) try
|
|||||||
}
|
}
|
||||||
|
|
||||||
_1d_array out_freq, out_power, out_std;
|
_1d_array out_freq, out_power, out_std;
|
||||||
out_freq.resize(150, 1.0, 1.0);
|
out_freq.resize(150);
|
||||||
|
out_freq.sequence(1.0, 1.0);
|
||||||
average_radian_spec(pro_freq, pro_spec, out_freq, out_power, out_std);
|
average_radian_spec(pro_freq, pro_spec, out_freq, out_power, out_std);
|
||||||
|
|
||||||
std::ofstream ofile;
|
std::ofstream ofile;
|
||||||
|
@ -31,8 +31,9 @@ using namespace gctl;
|
|||||||
|
|
||||||
int main(int argc, char const *argv[])
|
int main(int argc, char const *argv[])
|
||||||
{
|
{
|
||||||
_1d_array a(10, 1.0, 0.1);
|
_1d_array a(10);
|
||||||
_1d_array b(10, 1.0);
|
_1d_array b(10, 1.0);
|
||||||
|
a.sequence(1.0, 1.0);
|
||||||
|
|
||||||
_1d_array c(10);
|
_1d_array c(10);
|
||||||
veccpy(c, a, 2.0);
|
veccpy(c, a, 2.0);
|
||||||
|
@ -39,7 +39,8 @@ int main(int argc, char const *argv[]) try
|
|||||||
//array<double> xs = {-2.2, -1.8, -1.5, -1.0, -0.7, -0.2, 0.9, 1.3, 1.9, 2.5};
|
//array<double> xs = {-2.2, -1.8, -1.5, -1.0, -0.7, -0.2, 0.9, 1.3, 1.9, 2.5};
|
||||||
//ml.init(xs, std);
|
//ml.init(xs, std);
|
||||||
|
|
||||||
array<double> x(201, 0.1, 0.001);
|
array<double> x(201);
|
||||||
|
x.sequence(0.1, 0.001);
|
||||||
|
|
||||||
for (size_t i = 0; i < x.size(); i++)
|
for (size_t i = 0; i < x.size(); i++)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user