m_i*x_i''=k_{i+1}(x_{i+1}-x_i) -k_i(x_{i}-x_{i-1}), forces on the i-th floor, i>0
on the zero floor (ground floor) acts also analogous restorative force proportional to the shift relative to the ground: i.e.f(t)=G*sin(gamma t)
acts on the ground floor (level 0) e.g .gamma=3.for(){ }, while(){ }, do{ } while()
,
option - p should be given interactively from the keyboard by an user
fopen(), fclose(), fwrite(), fread(),
fprintf(), fscanf(), fgetchar() feof()etc
Write a code that will write a vector (double
array)to a file - binary or ascii (text) file
then another code that will read it from the file.
Test for: [1 2 3 4 -9.45].
float,double
etc.
Write a a C function generating a vector sin(x)
for a given vector x (e.g. equidistant points on [a,b]) -
parameters : a pointer to x (or ends of interval - easier version))
and pointer to returned vector with sin(x) - C function should allocate memory
and write to that memory sin(x), optionally export this vector to
binary file (fwrite()
)
and then read it back to memory to another memory address.
#define #if
etc
Modify the code from the previous function in such a way that depending on the precompiler options it will work either for doubles or floats (single
precision).
float
array in C. Then show the matrix on the computer display, i.e. save a matrix in text format in octave and then display by your C programm - check if it is OK.
(2)Write another C code which writes a matrix from C to text file in a default text format of octave. Read it using octave - check if it works.
(3)Try another wrtitng to other octave formats (ascii files) - or to binary octave format - (difficult - one has to find details of octave binary format)
#include
"mojblas.h"
) with the proper headers of this functions (in order to use them in your C code)
dgtsv()
solve the tridiagonal system
system Ax=f with the tridiagonal matrix A with 7 on the main diagonal, -2 on superdiagonal,
and -1 on subdiagonal for f=[7;-1;0;0;..;0] for N=15.Check if you get the right solution!
dnrm2()
and ddot()
dnrm2()
function - and dynamically allocating memory (using
malloc(); free()
functions
-u''+u=0; u(0)=u(T)=1
Apply the shooting method, namely, solve IVP-u''+u=0; u(0)=1; u'(0)=s
getting u(t,s) (practically numerically using lsode()). Find s0 s.t. u(t;s0)=1. It is enough to shoot twice i.e. take s2=1 and s1=0 and compute using lsode() u(t;0) and u(t;1). Then our s0=(1-u(T,0))/(u(T,1)-u(T,0)) (why?). Then compute u(T;s0) using lsode() and |u(T;s0)-1|. Why is the error growing with T?-u''+c*u =f
u(a)=alpha, u(b)=beta