42 if (i<0 || i>2)
_errorr (
"i out of the range");
44 return ((i==0) ? x : ((i==1) ? y : z));
49 if (i<0 || i>2)
_errorr (
"i out of the range");
51 return ((i==0) ? x : ((i==1) ? y : z));
59 Elem3D*
tms (
double val) { x *= val; y *= val; z *= val;
return this; }
60 Elem3D*
dvd (
double val) { x /= val; y /= val; z /= val;
return this; }
63 Elem3D*
add (
const double *p) { x += p[0]; y += p[1]; z += p[2];
return this; }
66 Elem3D*
round2abszero (
double zr) {
if (fabs(x)<zr) x=0.0;
if (fabs(y)<zr) y=0.0;
if (fabs(z)<zr) z=0.0;
return this; }
69 bool scan_x (FILE *stream) {
return ( fscanf (stream,
"%lf", &x) == 1); }
70 bool scan_y (FILE *stream) {
return ( fscanf (stream,
"%lf", &y) == 1); }
71 bool scan_z (FILE *stream) {
return ( fscanf (stream,
"%lf", &z) == 1); }
72 bool scan_xyz (FILE *stream) {
return ( fscanf (stream,
"%lf %lf %lf", &x, &y, &z) == 3); }
74 bool scan_xyz (
const double *src) { x = src[0]; y = src[1]; z = src[2];
return true; }
77 void copy_to (
double *dest)
const { dest[0] =
x; dest[1] =
y; dest[2] =
z; }
87 virtual void printYourself (
bool force=
false)
const { fprintf (stdout,
"PoinT [3]:\n% .*e % .*e % .*e\n",
PYP, x,
PYP, y,
PYP, z); }
110 x = 0.5 * (p1->
x + p2->
x + ksi * ( p2->
x - p1->
x ));
111 y = 0.5 * (p1->
y + p2->
y + ksi * ( p2->
y - p1->
y ));
112 z = 0.5 * (p1->
z + p2->
z + ksi * ( p2->
z - p1->
z ));
123 if (fabs(p1->
x - p2->
x) > fabs(p1->
y - p2->
y))
if (fabs(p1->
x - p2->
x) > fabs(p1->
z - p2->
z)) i = 0;
else i = 2;
124 else if (fabs(p1->
y - p2->
y) > fabs(p1->
z - p2->
z)) i = 1;
else i = 2;
126 ksi = 2.0 * ( (*this)[i] - (*p1)[i] ) / ( (*p2)[i] - (*p1)[i] ) - 1.0 ;
128 return ( fabs(ksi) < (1.0+
zero) );
140 double *a =
new double[3];
141 a[0] =
x; a[1] =
y; a[2] =
z;
166 x = v1->
y * v2->
z - v2->
y * v1->
z;
167 y = v1->
z * v2->
x - v2->
z * v1->
x;
168 z = v1->
x * v2->
y - v2->
x * v1->
y;
174 x = p2->
y*p3->
z - p3->
y*p2->
z + p1->
y*(p2->
z-p3->
z) - p1->
z*(p2->
y-p3->
y);
175 y = p2->
z*p3->
x - p3->
z*p2->
x + p1->
z*(p2->
x-p3->
x) - p1->
x*(p2->
z-p3->
z);
176 z = p2->
x*p3->
y - p3->
x*p2->
y + p1->
x*(p2->
y-p3->
y) - p1->
y*(p2->
x-p3->
x);
201 x = p->
x * cs - p->
y * sn;
202 y = p->
x * sn + p->
y * cs;
211 x = p->
x * cs + p->
y * sn;
212 y = - p->
x * sn + p->
y * cs;
222 if (l1/l2 < relZero || l2/l1 < relZero)
_warningg(
"Lengths of vectors are not proportional");
224 double v1x = this->
x/l1;
if (fabs(v1x) < relZero) v1x = 0.0;
225 double v1y = this->
y/l1;
if (fabs(v1y) < relZero) v1y = 0.0;
226 double v1z = this->
z/l1;
if (fabs(v1z) < relZero) v1z = 0.0;
228 double v2x = that->
x/l2;
if (fabs(v2x) < relZero) v2x = 0.0;
229 double v2y = that->
y/l2;
if (fabs(v2y) < relZero) v2y = 0.0;
230 double v2z = that->
z/l2;
if (fabs(v2z) < relZero) v2z = 0.0;
233 if (v1x*v2x < 0.0 || v1y*v2y < 0.0 || v1z*v2z < 0.0) sign = -1;
236 return (fabs(v1x-sign*v2x) < relZero && fabs(v1y-sign*v2y) < relZero && fabs(v1z-sign*v2z) < relZero);
245 return ( sqrt((a.
x*a.
x + a.
y*a.
y + a.
z*a.
z) / p1->
dist2_to(p2) ) );
258 double&
at11() {
return a[0]; }
259 double&
at12() {
return a[1]; }
260 double&
at13() {
return a[2]; }
261 double&
at21() {
return a[3]; }
262 double&
at22() {
return a[4]; }
263 double&
at23() {
return a[5]; }
264 double&
at31() {
return a[6]; }
265 double&
at32() {
return a[7]; }
266 double&
at33() {
return a[8]; }
269 void rotate (
double *v)
const;
286 #define SRCCHCK if (src==NULL) _errorr("source == NULL");
287 #define AVOID_CNST if (cnst) _errorr("cnst")
288 #define AVOID_EXTA if (exta) _errorr("exta")
314 virtual void printYourself (
bool force=
false)
const = 0;
336 virtual void print (
char *stream,
int precision,
double absZero=0.0)
const = 0;
377 virtual void printYourself (
bool force=
false)
const { fprintf (stdout,
"Double scalar: % .*e\n",
PYP, a); }
380 virtual void print (
char *stream,
int precision,
double absZero=0.0)
const;
401 Xvctr (
long s) :
Array1d() { exta = cnst =
false; shft = 0; size = asize = s; }
408 virtual void cpat (
long i,
const Xvctr *p,
long j) = 0;
409 virtual void shift (
long val) = 0;
411 virtual bool scan (
const char *&src) = 0;
419 double give_zero (
double abszero,
double relzero)
const;
426 virtual void print_vector (
char *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const = 0;
427 virtual void print_symtensor (
char *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const = 0;
428 virtual void print_symtensor (FILE *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const = 0;
457 if (i<0 || i>=
size)
_errorr (
"i out of the range");
466 _errorr (
"i out of the range");
474 if (
this == &src )
_errorr(
"oneself assignment");
480 memcpy (a, src.
a,
size*
sizeof(
long));
507 const Lvctr *pt =
dynamic_cast<const Lvctr *
>(p);
560 virtual void printYourself (
bool force)
const;
566 void print (
char *stream,
int precision,
double absZero=0.0 )
const;
567 void print_vector (
char *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const;
568 void print_symtensor (
char *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const;
569 void print_symtensor (FILE *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const;
603 if (i<0 || i>=
size)
_errorr (
"i out of the range");
610 _errorr (
"i out of the range");
636 const Dvctr *pt =
dynamic_cast<const Dvctr *
>(p);
665 void copy_to (
double *dest)
const { memcpy (dest, a,
size*
sizeof(
double)); }
690 void tmsby (
double val);
691 void dvdby (
double val);
704 double give_zero (
double abszero,
double relzero)
const;
710 virtual void printYourself (
bool force)
const;
716 void print (
char *stream,
int precision,
double absZero=0.0 )
const;
717 void print_vector (
char *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const;
718 void print_symtensor (
char *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const;
719 void print_symtensor (FILE *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const;
791 virtual void printYourself (
bool force=
false)
const;
855 virtual void printYourself (
bool force=
false)
const;
858 void print_tensor (FILE *stream,
int precision,
double absZero,
bool zerorest)
const;
865 #endif // GELIB_ARRAYS_H
virtual bool scan(const char *&src)=0
virtual ~Array()
DESTRUCTOR.
void print_symtensor(char *stream, int precision, double absZero=0.0, bool zerorest=false) const
virtual int length_printed(int precision) const =0
double give_dotproduct(const Dvctr &v) const
const long * give_ptr2val(long r=0, long c=0) const
bool give_ksiAtAbscissa(double zero, double norm, const PoinT *p1, const PoinT *p2, double &ksi) const
compute natural coordinate ksi of receiver at abscissa p1p2 answer: 1(0) = point lays on(out of) absc...
void print(char *stream, int precision, double absZero=0.0) const
virtual double give_lenght(void) const =0
void realloc(long newsize)
reallocate up receiver
Dvctr * resize_ignore_vals(long newsize)
virtual ~Lmtrx()
DESTRUCTOR.
VectoR * beP2P(const PoinT *p1, const PoinT *p2)
Receiver is set to vector from p1 to p2, i.e. 'this = p2 - p1'.
long give_size(void) const
void beCopyOf(const double *src)
bool scan_z(FILE *stream)
Lvctr * resize_preserve_vals(long newsize)
resize, keep values
void append(const Dvctr *src)
virtual ~Xmtrx()
DESTRUCTOR.
void beCopyOf(const Dvctr *src)
bool scan_y(FILE *stream)
long give_number_of_nonzeros(void) const
void beCopyOf(const Dvctr &src)
virtual ~Array1d()
DESTRUCTOR.
void be_mean_of(const Dmtrx *src)
virtual long give_size(void) const
double compute_squared_norm(void) const
virtual void print(char *stream, int precision, double absZero=0.0) const
void print(char *stream, int precision, double absZero=0.0) const
double give_length(void) const
double give_lenght(void) const
void resize_ignore_vals(long r, long c)
print yourself
arrayTypedef give_arrayTypedef(void) const
double operator[](long i) const
bool SP_scan_array(const char *&src, int n, ArgType *a)
... array of numbers
void rotate(Dvctr *v) const
double give_length_2d(void) const
void fillYourselfBy(int val)
Set all elements of the array to the given value.
arrayTypedef give_arrayTypedef(void) const
void beRotatedBy2d(const double *r)
Receiver will be rotated by 2d matrix 'rot'. this = rot . this.
long give_ccols(void) const
bool scan(const char *&src)
double & operator()(long r, long c)
void beCopyOf(const Dmtrx *src)
#define NUM_DIGITS_IN_PRINTED_EXPONENT
long * give_ptr2val(long r=0, long c=0)
void beRotatedBy(const double *r)
Receiver will be rotated by matrix 'rot'. this = rot . this.
void add_unique(long val)
add value to size++ position if unique
long give_sum(void) const
int length_printed_tensor(int precision) const
double giveScalProduct(const Elem3D *v) const
scalar product this * e
bool is_member(long val) const
Elem3D * copy(const Elem3D *p)
virtual void print(char *stream, int precision, double absZero=0.0) const =0
const long * give_ptr2val(long i=0) const
void bePointAtAbscissa(const PoinT *p1, const PoinT *p2, double ksi)
receiver will be point at abscissa p1p2 with natural coord ksi
void copy_to_row_1(const VectoR *v)
long & operator()(long r, long c)
VectoR * beVectProduct(const VectoR *v1, const VectoR *v2)
vector product v1 x v2 (cross product)
Lvctr * assign_array(long *array, long s)
arrayTypedef give_arrayTypedef(void) const
void be_tnsr(const Dmtrx &src)
void sbt(const Dvctr &src)
void copy_row(long r, const Elem3D *v)
double give_lenght(void) const
void beRotatedPoint(const Dmtrx *rot, const PoinT *point)
Receiver will be point 'point' rotated by matrix 'rot'. this = rot . point.
bool scan_xyz(const char *&src)
long is_member_of_array(ArgType val, long n, const ArgType *array)
check out "val" is member of "array"
void be_tnsr(const Dvctr &src)
double give_determinant(void) const
Dvctr * resize_preserve_vals(long newsize)
void print_vector(char *stream, int precision, double absZero=0.0, bool zerorest=false) const
PoinT * copy(const PoinT *p)
const double * give_ptr2val(long i=0) const
long give_number_of_zeros(void) const
virtual void print_symtensor(char *stream, int precision, double absZero=0.0, bool zerorest=false) const =0
Dvctr(long s, const double *src)
void beCopyOf(const PoinT &src)
void copy_to(double *dest) const
virtual long give_size(void) const =0
arrayClassType give_classid() const
double give_zero(double abszero, double relzero) const
Elem3D * round2abszero(double zr)
virtual void cpat(long i, const Xvctr *p, long j)=0
long operator[](long i) const
virtual int length_printed_tensor(int precision) const =0
VectoR * beVectProduct(const PoinT *p1, const PoinT *p2, const PoinT *p3, const PoinT *p4)
vector product p1p2 x p3p4
long give_number_of_nonzeros(void) const
bool scan_xyz(FILE *stream)
VectoR * be_rotSS_by_angle_2d(const VectoR *p, double a)
void beCopyOf(const double *src)
double operator[](int i) const
void tmsRightBy(const Dmtrx &src)
void copy_to_col_3(const VectoR *v)
void print_symtensor(char *stream, int precision, double absZero=0.0, bool zerorest=false) const
double * give_ptr2val(long r=0, long c=0)
Lvctr & operator=(const Lvctr &src)
void beCopyOf(const double *src, long s)
void tmsLeftBy(const Dmtrx &src)
void tnsrRotWith(const Dmtrx &rot)
this = rot * this * rot^transp
void add(long val)
add value to size++ position
int length_printed_vector(int precision) const
void print_tensor(FILE *stream, int precision, double absZero, bool zerorest) const
print yourself
Lvctr * resize_ignore_vals(long newsize)
resize, ignore values
const double & operator()(long r, long c) const
void copy_row(long r, const Dvctr &v)
int length_printed_vector(int precision) const
void copy_to_row_2(const VectoR *v)
void tnsrRotWith2(const Dmtrx &rot)
arrayClassType give_classid() const
void print_vector(char *stream, int precision, double absZero=0.0, bool zerorest=false) const
Elem3D * sub(const Elem3D *p)
bool scan(const char *&src)
virtual arrayTypedef give_arrayTypedef(void) const =0
Elem3D * add(const double *p)
bool is_parallel_with(const VectoR *that, double relZero) const
double give_zero(double abszero, double relzero) const
void tnsrRotWith1(const Dmtrx &rot)
void be_mtrxMmtrx(const Dmtrx &A, const Dmtrx &B)
const double * give_ptr2val(long r=0, long c=0) const
void tnsrRotAxisZangle(double a)
rotate coord system around axis z by angle
void cpat(long i, const Xvctr *p, long j)
int length_printed(int precision) const
void round2zero (double zero, double absZero);
virtual void print_vector(char *stream, int precision, double absZero=0.0, bool zerorest=false) const =0
VectoR * beVectProduct(const PoinT *p1, const PoinT *p2, const PoinT *p3)
vector product p1p2 x p1p3
void copy_to_col_1(const VectoR *v)
double dist_to_line(const PoinT *p1, const PoinT *p2) const
give distance from receiver to line defined by p1 and p2
void beCopyOf(const Dmtrx &src)
double dist_to(const PoinT *p) const
double give_sum(void) const
double give_angle_2d(void) const
long * give_ptr2val(long i=0)
return pointer to
void realloc(long newsize)
reallocate up receiver
Xvctr(long s)
CONSTRUCTOR.
virtual ~Xscal()
DESTRUCTOR.
arrayClassType give_classid() const
arrayTypedef give_arrayTypedef(void) const
bool GaussSolve(Dvctr &x, const Dvctr &rhs)
gaussian eliminatio
void copy_to_col_2(const VectoR *v)
Dvctr * assign_array(double *array, long s)
long give_crows(void) const
Lvctr(long s, const long *p)
bool isZero(double zero, double a)
virtual ~Lvctr()
DESTRUCTOR.
double operator()(void) const
void copy_to(double *dest) const
VectoR * copy(const VectoR *p)
bool is_identical_to(const Elem3D *p) const
virtual ~Dvctr()
DESTRUCTOR.
virtual ~Dscal()
DESTRUCTOR.
Elem3D * add(const Elem3D *p)
virtual void shift(long val)=0
bool scan_x(FILE *stream)
bool scan_xyz(const double *src)
double dist2_to(const PoinT *p) const
double * give_ptr2val(long i=0)
return pointer to
Dvctr * resize_to_asize(void)
void cpat(long i, const Xvctr *p, long j)
double norm(double val)
norma = delka vektoru, pro vektor delky 1 je to absolutni hodnota
VectoR * be_rot_by_angle_2d(const VectoR *p, double a)
virtual ~Dmtrx()
DESTRUCTOR.
virtual int length_printed_vector(int precision) const =0
void add(const Dvctr &src)
bool SP_skip_word(const char *&src, int n)
... word and space before
void be_transposition(const Dmtrx &src)
virtual arrayClassType give_classid() const =0
virtual int length_printed(int precision) const
void copy_to_row_3(const VectoR *v)
int length_printed(int precision) const
void resize_ignore_vals(long r, long c)
Lvctr * resize_to_asize(void)
resize to asize
int length_printed_tensor(int precision) const
void addtms(const Dvctr &src, double tms)
virtual ~Xvctr()
DESTRUCTOR.
const long & operator()(long r, long c) const
arrayTypedef give_arrayTypedef(void) const
double give_sum(void) const
sum of components
void be_vectproduct(const Dvctr &v1, const Dvctr &v2)
bool is_identical_to(const Elem3D *p, double zero) const