36 using std::runtime_error;
63 cout <<
"v.nelem() = " << v.
nelem() <<
"\n";
68 cout <<
"v.begin() = " << *v.
begin() <<
"\n";
70 cout <<
"v = \n" << v <<
"\n";
77 cout <<
"v2 = \n" << v2 <<
"\n";
79 for (
Index i=0 ; i<1000; ++i)
89 cout <<
"v = \n" << v <<
"\n";
90 cout <<
"v2 = \n" << v2 <<
"\n";
91 cout <<
"v2.nelem() = \n" << v2.
nelem() <<
"\n";
97 cout <<
"\nv3 = \n" << v3 <<
"\n";
99 cout <<
"\nv3 after junking v2 = \n" << v3 <<
"\n";
101 cout <<
"\nv3 after *2 = \n" << v3 <<
"\n";
111 cout <<
"\nM =\n" << M <<
"\n";
113 cout <<
"\nM(Range(2,4),Range(2,4)) =\n" <<
M(
Range(2,4),
Range(2,4)) <<
"\n";
115 cout <<
"\nM(Range(2,4),Range(2,4))(Range(1,2),Range(1,2)) =\n" 118 cout <<
"\nM(1,Range(joker)) =\n" <<
M(1,
Range(
joker)) <<
"\n";
120 cout <<
"\nFilling M(1,Range(1,2)) with junk.\n";
123 cout <<
"\nM(Range(0,4),Range(0,4)) =\n" <<
M(
Range(0,4),
Range(0,4)) <<
"\n";
125 cout <<
"\nFilling M(Range(4,2,2),Range(6,3)) with junk.\n";
130 cout <<
"\nM =\n" << M <<
"\n";
134 cout <<
"\nC(Range(3,4,2),Range(2,3,3)) =\n" 137 cout <<
"\nC(Range(3,4,2),Range(2,3,3)).transpose() =\n" 147 cout <<
"v.nelem() = " << v.
nelem() <<
"\n";
169 cout <<
"a = \n" << a <<
"\n";
170 cout <<
"b = \n" << b <<
"\n";
171 cout <<
"a*b \n= " << a*b <<
"\n";
183 cout <<
"\nB*C =\n" << A <<
"\n";
197 cout <<
"b = \n" << b <<
"\n";
198 cout <<
"M =\n" << M <<
"\n";
201 cout <<
"\na = M*b = \n" << a <<
"\n";
216 cout <<
"Transforming.\n";
220 for (
Index i=0; i<1000; ++i)
223 transform(y,sin,static_cast<MatrixView>(x));
236 cout <<
"min(sin(x)), max(sin(x)) = " <<
min(y) <<
", " <<
max(y) <<
"\n";
244 cout <<
"Done." <<
"\n";
252 cout <<
"B = " << B <<
"\n";
263 cout <<
"M = " << M <<
"\n";
275 cout <<
"M = " << M <<
"\n";
289 cout <<
"sb = \n" << sb <<
"\n";
293 cout <<
"sc = \n" << sc <<
"\n";
305 cout <<
"M = \n" << M <<
"\n";
313 Array<Numeric> c =
MakeArray<Numeric>(1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0);
314 cout <<
"a = \n" << a <<
"\n";
315 cout <<
"b = \n" << b <<
"\n";
316 cout <<
"c = \n" << c <<
"\n";
322 String a =
"Nur ein Test.";
323 cout <<
"a = " << a <<
"\n";
325 cout <<
"b = " << b <<
"\n";
346 cout <<
"a.sum() = " << a.
sum() <<
"\n";
354 cout <<
"a *= a =\n" << a <<
"\n";
365 cout <<
"a =\n" << a <<
"\n";
366 cout <<
"b =\n" << b <<
"\n";
373 cout <<
"a =\n" << a <<
"\n";
380 cout <<
"By reference:\n";
381 for (
Index i=0; i<1e8; ++i )
386 cout <<
"s = " << s <<
"\n";
393 cout <<
"By value:\n";
394 for (
Index i=0; i<1e8; ++i )
399 cout <<
"s = " << s <<
"\n";
406 cout <<
"a =\n" << a <<
"\n";
408 cout <<
"b =\n" << b <<
"\n";
417 cout <<
"a*=b =\n" << a <<
"\n";
419 cout <<
"a/=b =\n" << a <<
"\n";
421 cout <<
"a+=b =\n" << a <<
"\n";
423 cout <<
"a-=b =\n" << a <<
"\n";
429 MakeArray<Index> a(1,2,3,4,5,6,5,4,3,2,1);
430 cout <<
"min/max of a = " <<
min(a) <<
"/" <<
max(a) <<
"\n";
435 cout <<
"Test filling constructor for Array:\n";
437 cout <<
"a =\n" << a <<
"\n";
442 cout <<
"Test Arrays of Vectors:\n";
445 a.push_back(
Vector(1.0,10,1.0));
446 cout <<
"a =\n" << a <<
"\n";
451 cout <<
"Test default constructor for Matrix:\n";
454 cout <<
"b =\n" << b <<
"\n";
459 cout <<
"Test Arrays of Matrix:\n";
479 cout <<
"a =\n" << a <<
"\n";
484 cout <<
"Test Matrices of size 0:\n";
489 cout <<
"a =\n" << a <<
"\n";
495 cout <<
"b =\n" << b <<
"\n";
501 cout <<
"c =\n" << c <<
"\n";
506 cout <<
"Test Tensor3:\n";
518 cout <<
"a =\n" << a <<
"\n";
520 cout <<
"Taking out first row of first page:\n" 523 cout <<
"Taking out last column of second page:\n" 526 cout <<
"Taking out the first letter on every page:\n" 529 cout <<
"Taking out first page:\n" 532 cout <<
"Taking out last row of all pages:\n" 535 cout <<
"Taking out second column of all pages:\n" 540 cout <<
"After element-vise multiplication with 2:\n" 545 cout <<
"After taking the square-root:\n" 549 cout <<
"Let's allocate a large tensor, " 550 << (
Numeric)(s*s*s*8)/1024./1024.
555 cout <<
"Set it to 1...\n";
559 cout <<
"a(900,900,900) = " << a(90,90,90) <<
"\n";
563 cout <<
"Fill with running numbers, using for loops...\n";
564 for (
Index i=0; i<a.npages(); ++i )
565 for (
Index j=0; j<a.nrows(); ++j )
566 for (
Index k=0; k<a.ncols(); ++k )
569 cout <<
"Max(a) = ...\n";
571 cout <<
max(a) <<
"\n";
577 cout <<
"Test von X = A*X:\n";
578 Matrix X(3,3),A(3,3),B(3,3);
580 for (
Index j=0; j<A.nrows(); ++j )
581 for (
Index k=0; k<A.ncols(); ++k )
586 cout <<
"A:\n" << A <<
"\n";
587 cout <<
"X:\n" << X <<
"\n";
590 cout <<
"B = A*X:\n" << B <<
"\n";
592 cout <<
"X = A*X:\n" << X <<
"\n";
594 cout <<
"This is not the same, and should not be, because you\n" 595 <<
"are not allowed to use the same matrix as input and output\n" 601 cout <<
"Making things look bigger than they are...\n";
604 cout <<
"1. Make a scalar look like a vector:\n";
607 cout <<
"a, viewed as a vector: " << av <<
"\n";
608 cout <<
"Describe a: " <<
describe(a) <<
"\n";
610 cout <<
"a, after the first element\n" 611 <<
"of the vector has been increased by 1: " << a <<
"\n";
615 cout <<
"\n2. Make a vector look like a matrix:\n" 616 <<
"This is an exception, because the new dimension is added at the end.\n";
619 cout <<
"a, viewed as a matrix:\n" << am <<
"\n";
620 cout <<
"Trasnpose view:\n" <<
transpose(am) <<
"\n";
623 cout <<
"\n3. Make a matrix look like a tensor3:\n";
625 cout <<
"at3 = \n" << at3 <<
"\n";
626 cout <<
"Describe at3: " <<
describe(at3) <<
"\n";
628 cout <<
"a after Increasing element at3(0,2,0) by 1: \n" << a <<
"\n\n";
631 cout <<
"at4 = \n" << at4 <<
"\n";
632 cout <<
"Describe at4: " <<
describe(at4) <<
"\n";
635 cout <<
"at5 = \n" << at5 <<
"\n";
636 cout <<
"Describe at5: " <<
describe(at5) <<
"\n";
639 cout <<
"at6 = \n" << at6 <<
"\n";
640 cout <<
"Describe at6: " <<
describe(at6) <<
"\n";
643 cout <<
"at7 = \n" << at7 <<
"\n";
644 cout <<
"Describe at7: " <<
describe(at7) <<
"\n";
646 at7(0,0,0,0,0,2,0) -=1 ;
648 cout <<
"After subtracting 1 from at7(0,0,0,0,0,2,0)\n" 649 <<
"a = " << a <<
"\n";
651 cout <<
"\nAll in one go:\n";
665 cout <<
"bt7:\n" << bt7 <<
"\n";
666 cout <<
"Describe bt7: " <<
describe(bt7) <<
"\n";
672 cout <<
"Describe a: " <<
describe(a) <<
"\n";
677 cout <<
"Describe a: " <<
describe(a) <<
"\n";
682 cout <<
"Test, if dimension expansion works implicitly.\n";
693 cout <<
"Test the new copy semantics.\n";
698 cout <<
"b = " << b <<
"\n";
703 cout <<
"b = " << b <<
"\n";
708 cout <<
"b = " << b <<
"\n";
713 cout <<
"Test using naked joker on Vector.\n";
716 cout <<
"a = " << a <<
"\n";
717 cout <<
"b = " << b <<
"\n";
722 Vector v1(5e-15, 10, 0.42e-15/11);
744 cout << endl <<
"========================" << endl << endl;
752 cout << endl <<
"========================" << endl << endl;
791 cout <<
"Vector: " << v1 << endl;
792 cout <<
"VectorView: " << vv << endl;
796 }
catch (runtime_error e) {
797 std::cerr << e.what() << endl;
801 cout <<
"VectorView: " << vv << endl;
802 cout <<
"Vector: " << v1 << endl;
812 cout <<
"x: " << x << endl;
815 cout <<
"y: " << y << endl;
818 cout <<
"z:\n" << z << endl;
820 cout <<
"Every other z:\n" << z(
Range(1,2,2),
joker) << endl;
825 cout <<
"zz:\n" << zz << endl;
826 cout <<
"New x: " << x << endl;
835 cout << r2+r << endl;
843 #define docheck(fn, val, expect) \ 844 cout << #fn << "(" << val << ") = " << fn(x) << " (expected " << #expect << ")" << std::endl; 908 std::cout<<pow(0,0.3)<<std::endl;
909 ArrayOfIndex N;N=
MakeArray<Index>(1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15, 17, 17, 19, 19, 21, 21, 23, 23, 25, 25, 27, 27, 29, 29,
910 31, 31, 33, 33, 35, 35, 37, 37);
911 ArrayOfIndex J;J=
MakeArray<Index>(0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30,
912 30, 32, 32, 34, 34, 36, 36, 38);
926 sqrt(2*Nl.toNumeric()+1)*
928 sqrt(2*Nl.toNumeric()+1)*
932 pow(-1., (Nk+Nl+L+1).toNumeric());
935 std::cout <<
" " << A;
937 std::cout << std::endl;
943 d[II] =
wigner6j(1, 1, 1, J[II], N[II], N[II]) * pow(-1.,2.*(
Numeric)N[II]) * sqrt(6*(2*N[II]+1)*(2*J[II]+1));
945 std::cout<<d<<std::endl;
INDEX Index
The type to use for all integer numbers and indices.
void junk2(ConstVectorView a)
ConstMatrixView transpose(ConstMatrixView m)
Const version of transpose.
Index nelem() const
Number of elements.
Explicit construction of Arrays.
String describe(ConstTensor7View x)
Describe Tensor7.
const Numeric * get_c_array() const
Conversion to plain C-array.
Header file for describe.cc.
bool is_increasing(ConstVectorView x)
Checks if a vector is sorted and strictly increasing.
ConstIterator1D begin() const
Return const iterator to first element.
Numeric wigner6j(const Rational j1, const Rational j2, const Rational j3, const Rational J1, const Rational J2, const Rational J3)
void fill_with_junk(VectorView x)
Index nrows() const
Returns the number of rows.
Index nelem() const
Returns the number of elements.
This file contains the definition of Array.
void mult(VectorView y, const ConstMatrixView &M, const ConstVectorView &x)
Matrix Vector multiplication.
Index ncols() const
Returns the number of columns.
const Numeric * get_c_array() const
Conversion to plain C-array.
Numeric by_value(Numeric x)
Header file for sparse matrices.
Numeric toNumeric() const
bool is_sorted(ConstVectorView x)
Checks if a vector is sorted in ascending order.
Index ncols() const
Returns the number of columns.
Numeric by_reference(const Numeric &x)
Numeric sum() const
The sum of all elements of a Vector.
void junk4(Tensor4View a)
The declarations of all the exception classes.
NUMERIC Numeric
The type to use for all floating point numbers.
Implements the class MakeArray, which is a derived class of Array, allowing explicit initialization...
#define docheck(fn, val, expect)
Header file for logic.cc.
Index npages() const
Returns the number of pages.
The class MakeVector is a special kind of Vector that can be initialized explicitly from one or more ...
void resize(Index n)
Assignment operator from VectorView.
A constant view of a Vector.
void test37(const Index &i)
Contains the rational class definition.
A constant view of a Matrix.
void transform(VectorView y, double(&my_func)(double), ConstVectorView x)
A generic transform function for vectors, which can be used to implement mathematical functions opera...
Numeric ECS_wigner(Rational L, Rational Nl, Rational Nk, Rational Jk_lower, Rational Jl_lower, Rational Jk_upper, Rational Jl_upper)
bool is_decreasing(ConstVectorView x)
Checks if a vector is sorted in reversed order and is strictly decreasing.
const Numeric * get_c_array() const
Conversion to plain C-array.
Index nrows() const
Returns the number of rows.
This file contains the definition of String, the ARTS string class.
void resize(Index r, Index c)
Resize function.