-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting_generic_value.cpp
More file actions
85 lines (64 loc) · 1.59 KB
/
testing_generic_value.cpp
File metadata and controls
85 lines (64 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// testing_generic_value.hpp
// author: Antonio C. Domínguez Brito <antonio.dominguez@ulpgc.es>
// creation date: november 16th 2025
// Description: This is a program for testing generic_value classes
#include <iostream>
using namespace std;
#include "generic_value.hpp"
using gv=generic_value<double>;
int main(int arc, char* argv[])
try
{
cout<<"This a program for testing generic_value classes"<<endl;
gv a(
matrix<double>{
{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12}
}
);
cout<<"a="<<a<<endl;
gv b(.123456);
cout<<"b="<<b<<endl;
cout<<"a/b="<<a/b<<endl;
cout<<"a%3="<<a%gv(3)<<endl;
cout<<"b*a="<<b*a<<endl;
cout<<"b*a%3="<<b*a%3<<endl;
cout<<"(10+b)%3="<<(gv(10)+b)%3<<endl;
gv c(
matrix<double>{
{12, 11, 10, 9},
{8, 7, 6, 5},
{4, 3, 2, 1}
}
);
cout<<"c="<<c<<endl;
gv d(3);
cout<<"d="<<d<<endl;
cout<<"d*b="<<d*b<<endl;
cout<<"~a="<<~a<<endl;
cout<<"-a="<<-a<<endl;
cout<<"a*(~a)="<<a*~a<<endl;
cout<<"a*4+a="<<a*gv(4)+a<<endl;
cout<<"4*a+a="<<gv(4)*a+a<<endl;
cout<<"a+c="<<a+c<<endl;
cout<<"a-c="<<a-c<<endl;
gv i(
matrix<double>{
{1, 0, 0},
{0, 1, 0},
{0, 0, 1},
}
);
cout<<"i="<<i<<endl;
cout<<"i*i="<<i*i<<endl;
auto k=a-c+gv(3)*a;
cout<<"k=a-c+3*a="<<k<<endl;
//cout<<"cos(a)="<<a.call_function(cos)<<endl;
//cout<<"cos(b)="<<b.call_function(cos)<<endl;
//cout<<"pow(a,2)="<<a.call_function(pow,gv(2))<<endl;
//cout<<"pow(b,a)="<<b.call_function(pow,a)<<endl;
return 0;
}
catch(exception& e)
{ cerr<<"\n[EXCEPTION] "<<e.what()<<endl; }