NUMCXX
0.13.20181108
Numerical library for small projects and teaching purposes
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
examples
20-numcxx-graphics
20-numcxx-matplotlib.cxx
Go to the documentation of this file.
1
//
2
// /net/wir/numcxx/examples/20-graphics/20-numcxx-matplotlib.py
3
//
4
#include <
numcxx/numcxx.hxx
>
5
#include <cstdio>
6
#include <cmath>
7
8
9
int
main
(
void
)
10
{
11
const
double
x0=0.0;
12
const
double
x1=1.0;
13
double
h=0.01;
14
double
t0=0.0;
15
double
t1=10.0;
16
double
dt=0.01;
17
18
const
int
N=1+ceil((x1-x0)/h);
19
h=(x1-x0)/(
double
)(N-1);
20
21
numcxx::DArray1
X(N);
22
numcxx::DArray1
U(N);
23
24
X(0)=x0;
25
for
(
int
i=1;i<N;i++)
26
{
27
X(i)=X(i-1)+h;
28
}
29
30
for
(
int
i=0; i<N; i++)
31
{
32
U(i)=sin(20.0*X(i));
33
}
34
numcxx::savetxt
(
"20-plot-X.dat"
,X);
35
numcxx::savetxt
(
"20-plot-U.dat"
,U);
36
37
}
38
39
numcxx::savetxt
void savetxt(const std::string fname, const TArray< T > &a)
Definition:
util.ixx:114
numcxx.hxx
Main header of the library.
numcxx::TArray1
One dimensional array class.
Definition:
tarray1.hxx:31
main
int main(void)
Definition:
20-numcxx-matplotlib.cxx:9
Generated on Thu Nov 8 2018 22:52:26 for NUMCXX by
1.8.11