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; }
68 bool scan_x (FILE *stream) {
return ( fscanf (stream,
"%lf", &
x) == 1); }
69 bool scan_y (FILE *stream) {
return ( fscanf (stream,
"%lf", &
y) == 1); }
70 bool scan_z (FILE *stream) {
return ( fscanf (stream,
"%lf", &
z) == 1); }
71 bool scan_xyz (FILE *stream) {
return ( fscanf (stream,
"%lf %lf %lf", &
x, &
y, &
z) == 3); }
73 bool scan_xyz (
const double *src) {
x = src[0];
y = src[1];
z = src[2];
return true; }
76 void copy_to (
double *dest)
const { dest[0] =
x; dest[1] =
y; dest[2] =
z; }
86 virtual void printYourself (
bool force=
false)
const { fprintf (stdout,
"PoinT [3]:\n% .*e % .*e % .*e\n",
PYP,
x,
PYP,
y,
PYP,
z); }
109 x = 0.5 * (p1->
x + p2->
x + ksi * ( p2->
x - p1->
x ));
110 y = 0.5 * (p1->
y + p2->
y + ksi * ( p2->
y - p1->
y ));
111 z = 0.5 * (p1->
z + p2->
z + ksi * ( p2->
z - p1->
z ));
122 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;
123 else if (fabs(p1->
y - p2->
y) > fabs(p1->
z - p2->
z)) i = 1;
else i = 2;
125 ksi = 2.0 * ( (*this)[i] - (*p1)[i] ) / ( (*p2)[i] - (*p1)[i] ) - 1.0 ;
127 return ( fabs(ksi) < (1.0+
zero) );
135 double *a =
new double[3];
136 a[0] =
x; a[1] =
y; a[2] =
z;
161 x = v1->
y * v2->
z - v2->
y * v1->
z;
162 y = v1->
z * v2->
x - v2->
z * v1->
x;
163 z = v1->
x * v2->
y - v2->
x * v1->
y;
169 x = p2->
y*p3->
z - p3->
y*p2->
z + p1->
y*(p2->
z-p3->
z) - p1->
z*(p2->
y-p3->
y);
170 y = p2->
z*p3->
x - p3->
z*p2->
x + p1->
z*(p2->
x-p3->
x) - p1->
x*(p2->
z-p3->
z);
171 z = p2->
x*p3->
y - p3->
x*p2->
y + p1->
x*(p2->
y-p3->
y) - p1->
y*(p2->
x-p3->
x);
195 if (l1/l2 < relZero || l2/l1 < relZero)
_warningg(
"Lengths of vectors are not proportional");
197 double v1x = this->
x/l1;
if (fabs(v1x) < relZero) v1x = 0.0;
198 double v1y = this->
y/l1;
if (fabs(v1y) < relZero) v1y = 0.0;
199 double v1z = this->
z/l1;
if (fabs(v1z) < relZero) v1z = 0.0;
201 double v2x = that->
x/l2;
if (fabs(v2x) < relZero) v2x = 0.0;
202 double v2y = that->
y/l2;
if (fabs(v2y) < relZero) v2y = 0.0;
203 double v2z = that->
z/l2;
if (fabs(v2z) < relZero) v2z = 0.0;
206 if (v1x*v2x < 0.0 || v1y*v2y < 0.0 || v1z*v2z < 0.0) sign = -1;
209 return (fabs(v1x-sign*v2x) < relZero && fabs(v1y-sign*v2y) < relZero && fabs(v1z-sign*v2z) < relZero);
218 return ( sqrt((a.
x*a.
x + a.
y*a.
y + a.
z*a.
z) / p1->
dist2_to(p2) ) );
242 void rotate (
double *v)
const;
259 #define SRCCHCK if (src==NULL) _errorr("source == NULL");
260 #define AVOID_CNST if (cnst) _errorr("cnst")
261 #define AVOID_EXTA if (exta) _errorr("exta")
287 virtual void printYourself (
bool force=
false)
const = 0;
309 virtual void print (
char *stream,
int precision,
double absZero=0.0)
const = 0;
350 virtual void printYourself (
bool force=
false)
const { fprintf (stdout,
"Double scalar: % .*e\n",
PYP,
a); }
353 virtual void print (
char *stream,
int precision,
double absZero=0.0)
const;
381 virtual void cpat (
long i,
const Xvctr *p,
long j) = 0;
382 virtual void shift (
long val) = 0;
384 virtual bool scan (
const char *&src) = 0;
392 double give_zero (
double abszero,
double relzero)
const;
399 virtual void print_vector (
char *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const = 0;
400 virtual void print_symtensor (
char *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const = 0;
401 virtual void print_symtensor (FILE *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const = 0;
430 if (i<0 || i>=
size)
_errorr (
"i out of the range");
439 _errorr (
"i out of the range");
447 if (
this == &src )
_errorr(
"oneself assignment");
453 memcpy (
a, src.
a,
size*
sizeof(
long));
480 const Lvctr *pt =
dynamic_cast<const Lvctr *
>(p);
533 virtual void printYourself (
bool force)
const;
539 void print (
char *stream,
int precision,
double absZero=0.0 )
const;
540 void print_vector (
char *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const;
541 void print_symtensor (
char *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const;
542 void print_symtensor (FILE *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const;
576 if (i<0 || i>=
size)
_errorr (
"i out of the range");
583 _errorr (
"i out of the range");
609 const Dvctr *pt =
dynamic_cast<const Dvctr *
>(p);
638 void copy_to (
double *dest)
const { memcpy (dest,
a,
size*
sizeof(
double)); }
663 void tmsby (
double val);
664 void dvdby (
double val);
675 double give_zero (
double abszero,
double relzero)
const;
681 virtual void printYourself (
bool force)
const;
687 void print (
char *stream,
int precision,
double absZero=0.0 )
const;
688 void print_vector (
char *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const;
689 void print_symtensor (
char *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const;
690 void print_symtensor (FILE *stream,
int precision,
double absZero=0.0,
bool zerorest=
false)
const;
762 virtual void printYourself (
bool force=
false)
const;
826 virtual void printYourself (
bool force=
false)
const;
829 void print_tensor (FILE *stream,
int precision,
double absZero,
bool zerorest)
const;
836 #endif // MIDAS_ARRAYS_H
arrayClassType give_classid() const
virtual void print_symtensor(char *stream, int precision, double absZero=0.0, bool zerorest=false) const =0
bool is_parallel_with(const VectoR *that, double relZero) const
Lvctr * resize_preserve_vals(long newsize)
resize, keep values
virtual ~Dvctr()
DESTRUCTOR.
void beCopyOf(const double *src)
virtual ~Array()
DESTRUCTOR.
Xvctr(long s)
CONSTRUCTOR.
virtual double give_lenght(void) const =0
virtual void print(char *stream, int precision, double absZero=0.0) const =0
Elem3D * round2abszero(double zr)
long * give_ptr2val(long r=0, long c=0)
virtual void print_vector(char *stream, int precision, double absZero=0.0, bool zerorest=false) const =0
double & operator()(long r, long c)
virtual ~Dmtrx()
DESTRUCTOR.
Dvctr * resize_preserve_vals(long newsize)
double dist2_to(const PoinT *p) const
Lvctr & operator=(const Lvctr &src)
int length_printed_vector(int precision) const
bool GaussSolve(Dvctr &x, const Dvctr &rhs)
gaussian eliminatio
int length_printed(int precision) const
void round2zero (double zero, double absZero);
void tmsLeftBy(const Dmtrx &src)
bool scan_z(FILE *stream)
const long * give_ptr2val(long r=0, long c=0) const
double give_zero(double abszero, double relzero) const
int length_printed(int precision) const
virtual long give_size(void) const =0
bool is_identical_to(const Elem3D *p, double zero) const
virtual bool scan(const char *&src)=0
void copy_to_col_1(const VectoR *v)
double give_dotproduct(const Dvctr &v)
int length_printed_tensor(int precision) const
void append(const Dvctr *src)
const double * give_ptr2val(long i=0) const
void print_tensor(FILE *stream, int precision, double absZero, bool zerorest) const
print yourself
long give_size(void) const
void realloc(long newsize)
reallocate up receiver
virtual int length_printed_tensor(int precision) const =0
double give_sum(void) const
sum of components
Dvctr * resize_to_asize(void)
virtual int length_printed_vector(int precision) const =0
void copy_to_row_1(const VectoR *v)
void print_vector(char *stream, int precision, double absZero=0.0, bool zerorest=false) const
void be_mtrxMmtrx(const Dmtrx &A, const Dmtrx &B)
bool SP_skip_word(const char *&src, int n)
... word and space before
arrayTypedef give_arrayTypedef(void) const
void beRotatedPoint(const Dmtrx *rot, const PoinT *point)
Receiver will be point 'point' rotated by matrix 'rot'. this = rot . point.
virtual long give_size(void) const
long is_member_of_array(ArgType val, long n, const ArgType *array)
check out "val" is member of "array"
void realloc(long newsize)
reallocate up receiver
#define NUM_DIGITS_IN_PRINTED_EXPONENT
void tmsRightBy(const Dmtrx &src)
arrayClassType give_classid() const
virtual ~Lvctr()
DESTRUCTOR.
Lvctr * assign_array(long *array, long s)
bool is_identical_to(const Elem3D *p) const
void bePointAtAbscissa(const PoinT *p1, const PoinT *p2, double ksi)
receiver will be point at abscissa p1p2 with natural coord ksi
VectoR * beVectProduct(const PoinT *p1, const PoinT *p2, const PoinT *p3)
vector product p1p2 x p1p3
virtual arrayTypedef give_arrayTypedef(void) const =0
void copy_to_row_2(const VectoR *v)
arrayTypedef give_arrayTypedef(void) const
double dist_to_line(const PoinT *p1, const PoinT *p2) const
give distance from receiver to line defined by p1 and p2
double give_sum(void) const
long operator[](long i) const
double give_length(void) const
bool scan_x(FILE *stream)
bool scan(const char *&src)
double give_determinant(void) const
void be_transposition(const Dmtrx &src)
void resize_ignore_vals(long r, long c)
print yourself
void sbt(const Dvctr &src)
virtual ~Lmtrx()
DESTRUCTOR.
virtual ~Xmtrx()
DESTRUCTOR.
virtual int length_printed(int precision) const =0
void be_vectproduct(const Dvctr &v1, const Dvctr &v2)
virtual arrayClassType give_classid() const =0
arrayTypedef give_arrayTypedef(void) const
bool isZero(double zero, double a)
Dvctr * resize_ignore_vals(long newsize)
void beCopyOf(const PoinT &src)
long give_sum(void) const
bool scan_xyz(const char *&src)
double operator[](int i) const
Lvctr * resize_to_asize(void)
resize to asize
void tnsrRotWith2(const Dmtrx &rot)
void print_vector(char *stream, int precision, double absZero=0.0, bool zerorest=false) const
void print(char *stream, int precision, double absZero=0.0) const
void be_tnsr(const Dvctr &src)
void copy_to_col_3(const VectoR *v)
void copy_to(double *dest) const
VectoR * beVectProduct(const VectoR *v1, const VectoR *v2)
vector product v1 x v2 (cross product)
Lvctr(long s, const long *p)
arrayTypedef give_arrayTypedef(void) const
virtual int length_printed(int precision) const
double give_lenght(void) const
void beCopyOf(const Dvctr &src)
bool scan_xyz(FILE *stream)
void print(char *stream, int precision, double absZero=0.0) const
void copy_row(long r, const Dvctr &v)
void beCopyOf(const double *src)
void resize_ignore_vals(long r, long c)
Lvctr * resize_ignore_vals(long newsize)
resize, ignore values
double give_lenght(void) const
bool scan_y(FILE *stream)
void tnsrRotWith1(const Dmtrx &rot)
void add(const Dvctr &src)
void rotate(Dvctr *v) const
bool scan(const char *&src)
void add(long val)
add value to size++ position
Dvctr * assign_array(double *array, long s)
virtual void print(char *stream, int precision, double absZero=0.0) const
virtual ~Array1d()
DESTRUCTOR.
void be_mean_of(const Dmtrx *src)
int length_printed_tensor(int precision) const
virtual void cpat(long i, const Xvctr *p, long j)=0
long give_number_of_nonzeros(void) const
long & operator()(long r, long c)
virtual ~Xscal()
DESTRUCTOR.
double dist_to(const PoinT *p) const
void tnsrRotAxisZangle(double a)
rotate coord system around axis z by angle
double operator()(void) const
Elem3D * add(const Elem3D *p)
void tnsrRotWith(const Dmtrx &rot)
this = rot * this * rot^transp
void copy_to(double *dest) const
void be_tnsr(const Dmtrx &src)
double * give_ptr2val(long r=0, long c=0)
void fillYourselfBy(long val)
Set all elements of the array to the given value.
Elem3D * copy(const Elem3D *p)
void beCopyOf(const Dmtrx &src)
arrayClassType give_classid() const
bool SP_scan_array(const char *&src, int n, ArgType *a)
... array of numbers
VectoR * beP2P(const PoinT *p1, const PoinT *p2)
Receiver is set to vector from p1 to p2, i.e. 'this = p2 - p1'.
long give_number_of_zeros(void) const
void cpat(long i, const Xvctr *p, long j)
arrayTypedef give_arrayTypedef(void) const
double * give_ptr2val(long i=0)
return pointer to
virtual ~Xvctr()
DESTRUCTOR.
long give_number_of_nonzeros(void) const
virtual ~Dscal()
DESTRUCTOR.
long * give_ptr2val(long i=0)
return pointer to
bool scan_xyz(const double *src)
void addtms(const Dvctr &src, double tms)
void print_symtensor(char *stream, int precision, double absZero=0.0, bool zerorest=false) const
void beCopyOf(const Dvctr *src)
const double & operator()(long r, long c) const
void print_symtensor(char *stream, int precision, double absZero=0.0, bool zerorest=false) const
virtual void shift(long val)=0
double giveScalProduct(const Elem3D *v) const
scalar product this * e
void beCopyOf(const Dmtrx *src)
const long * give_ptr2val(long i=0) const
Dvctr(long s, const double *src)
void copy_to_col_2(const VectoR *v)
PoinT * copy(const PoinT *p)
const double * give_ptr2val(long r=0, long c=0) const
double operator[](long i) const
long give_ccols(void) const
const long & operator()(long r, long c) const
void add_unique(long val)
add value to size++ position if unique
void copy_to_row_3(const VectoR *v)
void copy_row(long r, const Elem3D *v)
bool is_member(long val) const
VectoR * copy(const VectoR *p)
Elem3D * sub(const Elem3D *p)
double give_zero(double abszero, double relzero) const
VectoR * beVectProduct(const PoinT *p1, const PoinT *p2, const PoinT *p3, const PoinT *p4)
vector product p1p2 x p3p4
int length_printed_vector(int precision) const
long give_crows(void) const
void beCopyOf(const double *src, long s)
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 cpat(long i, const Xvctr *p, long j)