45 return T1[0]*T2[0] + T1[1]*T2[1] + 2.0*T1[2]*T2[2];
59 printf(
"%s", notice );
60 for(
int i = 0; i < n; i++ ){
61 for(
int j = 0; j < m; j++ ){
63 printf(
"%.6e ", field[i][j] );
66 printf(
"%.6e ", 0. );
78 double *auxVec =
new double[dim];
81 auxVec[0] = tens[0] * vect[0] + tens[3] * vect[1] + tens[5] * vect[2];
82 auxVec[1] = tens[3] * vect[0] + tens[1] * vect[1] + tens[4] * vect[2];
83 auxVec[2] = tens[5] * vect[0] + tens[4] * vect[1] + tens[2] * vect[2];
86 auxVec[0] = tens[0] * vect[0] + tens[2] * vect[1];
87 auxVec[1] = tens[2] * vect[0] + tens[1] * vect[1];
89 else _errorr(
"unsupported dimension");
98 result[0] = tens[0] * vect[0] + tens[3] * vect[1] + tens[5] * vect[2];
99 result[1] = tens[3] * vect[0] + tens[1] * vect[1] + tens[4] * vect[2];
100 result[2] = tens[5] * vect[0] + tens[4] * vect[1] + tens[2] * vect[2];
103 result[0] = tens[0] * vect[0] + tens[2] * vect[1];
104 result[1] = tens[2] * vect[0] + tens[1] * vect[1];
106 else _errorr(
"unsupported dimension");
115 if( vect == result ){
118 auxVect[0] = T[0] * vect[0] + T[1] * vect[1] + T[2] * vect[2];
119 auxVect[1] = T[3] * vect[0] + T[4] * vect[1] + T[5] * vect[2];
120 auxVect[2] = T[6] * vect[0] + T[7] * vect[1] + T[8] * vect[2];
121 auxVect[3] = T[9] * vect[3];
122 auxVect[4] = T[10] * vect[4];
123 auxVect[5] = T[11] * vect[5];
129 result[0] = T[0] * vect[0] + T[1] * vect[1] + T[2] * vect[2];
130 result[1] = T[3] * vect[0] + T[4] * vect[1] + T[5] * vect[2];
131 result[2] = T[6] * vect[0] + T[7] * vect[1] + T[8] * vect[2];
132 result[3] = T[9] * vect[3];
133 result[4] = T[10] * vect[4];
134 result[5] = T[11] * vect[5];
143 if( vect == result ){
146 auxVect[0] = T[0] * vect[0] + T[1] * vect[1];
147 auxVect[1] = T[2] * vect[0] + T[3] * vect[1];
148 auxVect[2] = T[4] * vect[2];
154 result[0] = T[0] * vect[0] + T[1] * vect[1];
155 result[1] = T[2] * vect[0] + T[3] * vect[1];
156 result[2] = T[4] * vect[2];
164 vect[0] * ( T[0] * vect[0] + T[1] * vect[1]) +
165 vect[1] * ( T[2] * vect[0] + T[3] * vect[1]) +
166 vect[2] * ( T[4] * vect[2]);
172 if (result == T1 || result == T2) {
173 _errorr(
"in-place product not implemented yet");
176 result[0] = T1[0] * T2[0] + T1[1] * T2[2]; result[1] = T1[0] * T2[1] + T1[1] * T2[3];
177 result[2] = T1[2] * T2[0] + T1[3] * T2[2]; result[3] = T1[2] * T2[1] + T1[3] * T2[3];
179 result[4] = T1[4] * T2[4];
200 int i = 0, j = 0, k = 0;
202 printf(
"%s", notice );
203 for( i = 0; i < n; i++ ){
204 for( j = 0; j < m; j++, k++ ){
205 if( k == lineBreak ){
210 ( k == 0 )? printf(
"%.6e", field[i][j] ) : printf(
" %.6e", field[i][j] );
213 ( k == 0 )? printf(
"%.6e", 0. ) : printf(
" %.6e", 0. );
215 }printf(
"\n\n" ); k = 0;
232 const char * notice )
234 int i = 0, j = 0, k = 0;
236 printf(
"%s", notice );
237 for( i = 0; i < n; i++ ){
238 for( j = 0; j < m[i]; j++, k++ ){
239 if( k == lineBreak ){
244 ( k == 0 )? printf(
"%.6e", field[i][j] ) : printf(
" %.6e", field[i][j] );
247 ( k == 0 )? printf(
"%.6e", 0. ) : printf(
" %.6e", 0. );
249 }printf(
"\n\n" ); k = 0;
265 const char * notice )
267 int i = 0, j = 0, k = 0;
269 printf(
"%s", notice );
270 for( i = 0; i < n; i++ ){
271 for( j = 0; j < m[i]; j++, k++ ){
272 if( k == lineBreak ){
277 ( k == 0 )? printf(
"%d", field[i][j] ) : printf(
" %d", field[i][j] );
280 ( k == 0 )? printf(
"%d", 0 ) : printf(
" %d", 0 );
282 }printf(
"\n\n" ); k = 0;
290 void ludcmp(
double **a,
int n,
int *indx,
double *d)
293 double big,dum,temp=0;
302 if (temp > big) big=temp;
304 if (big == 0.0)
_errorr1(
"Singular matrix in routine ludcmp\n");
312 a[i][j] -= a[i][k]*a[k][j];
318 a[i][j] -= a[i][k]*a[k][j];
319 if((dum=vv[i]*fabs(a[i][j])) >= big)
349 void lubksb(
double **a,
int n,
int *indx,
double b[])
359 for (j=ii;j<i;j++) sum -= a[i][j]*b[j];
363 for (i=n-1;i>-1;i--) {
365 for (j=i+1;j<n;j++) sum -= a[i][j]*b[j];
381 if (mtrx == NULL)
_errorr(
"No matrix for inversion defined" );
382 if (n == 0 )
_errorr(
"Zero size of the matrix for inversion" );
404 if (mtrx == NULL)
_errorr(
"No matrix for inversion defined" );
405 if (n == 0 )
_errorr(
"Zero size of the matrix for inversion" );
427 if (answer == NULL)
_errorr (
"Field for answer must be allocated");
428 if (mtrx == NULL)
_errorr(
"No matrix for inversion defined" );
429 if (n == 0 )
_errorr(
"Zero size of the matrix for inversion" );
435 double *col =
new double [n];
436 int *indx =
new int [n];
438 ludcmp( mtrx, n, indx, &d );
440 for ( j=0; j<n; j++ ) {
441 for ( i=0; i<n; i++ ) col[i] = 0.0;
443 lubksb( mtrx, n, indx, col );
444 if (vect)
for ( i=0; i<n; i++ ) answer[0][i*n + j] = col[i];
445 else for ( i=0; i<n; i++ ) answer [i ][j] = col[i];
508 if (t[1] != t[3] || t[2] != t[6] || t[5] != t[7])
_errorr(
"tensor is not symmetrical");
513 t[6] = t[7] = t[8] = 0.0;
518 if (t[1] != t[2])
_errorr(
"tensor is not symmetrical");
void convert2Dtensor_TRtoVR_notation(double *t)
Function convert the symmetric double 2D tensor 't'.
void copy2DeshelbyTensor_reduced2full(const double *a, double **b)
Function copies and converts 2D eshelby/stiffness tensor saved in reduced row-wise vector 'a' to full...
void printField(double **field, int n, int m, const char *notice)
Function prints a field which is saved as 2D array.
double giveTTproduct_1is2x2to3and2x2to3_SS(const double *T1, const double *T2)
Function gives scalar left-right product of tensor and tensor.
void convert3Dtensor_9ROWto6FEEP_notation(double *t)
void convert2Dtensor_4ROWto3FEEP_notation(double *t)
void copy3DeshelbyTensor_reduced2full(const double *a, double **b)
Function copies and converts 3D eshelby/stiffness tensor saved in reduced row-wise vector 'a' to full...
Namespace MatrixOperations.
void CopyVector(const double *src, double *dest, long n)
Function copy given number of components from vector, 'a' to vector 'b'.
double giveVTVproduct_1is3and3x3to5and3(const double *T, const double *vect)
Function gives scalar left-right product of tensor and vector - 'result = vect^T * T * vect'...
void giveTVproduct_6is6x6to12and6(double *result, const double *T, const double *vect)
Function gives product of tensor and vector - 'result = T * vect'.
void printAnisoField(double **field, int n, int *m, int lineBreak, const char *notice)
Function prints an anisotropic field of type 'double' which is saved as 2D anisotropic array...
void CopyArray2D(const double *const *src, double **dest, long d1, long d2)
Function copy two 2D double arrays with dimensions d1xd2 from 'src' to 'dest'.
void copy2Dto3Dtensors_FEEPreduced(const double *a, double *b)
Function copy the symmetric double 2D tensor 'a' to 3D tensor 'b'.
The header file of usefull macros.
Collection of the functions of basic manipulations, some of them can be used instead of their counter...
void CleanArray2d(double **a, long rows, long columns)
Function cleans an 2d 'double' array, initialize each value being 0-zero.
void copy2DeshelbyTensor_full2reduced(const double *a, double *b)
Function copies and converts 2D eshelby/stiffness tensor saved in full row-wise vector 'a' to reduced...
void giveTTproduct_3x3to5is3x3to5and3x3to5(double *result, const double *T1, const double *T2)
Function gives product of tensor and tensor - 'result = T1 * T2'.
void convert3Dtensor_TRtoVR_notation(double *t)
Function convert the symmetric double 3D tensor 't'.
void convert2Dtensor_TRtoROW_notation(double *t)
Function convert the symmetric double 2D tensor 't'.
void giveIsoTensAndVectorProduct(const double *tens, const double *vec, double *result, int dim)
Function gives the product of the isotropic tensor of seccond order with a vector.
void lubksb(double **a, int n, int *indx, double b[])
void ludcmp(double **a, int n, int *indx, double *d)
void copy3DeshelbyTensor_full2reduced(const double *a, double *b)
Function copies and converts 3D eshelby/stiffness tensor saved in full row-wise vector 'a' to reduced...
void giveTVproduct_3is3x3to5and3(double *result, const double *T, const double *vect)
Function gives product of tensor and vector - 'result = T * vect'.
void convert3Dtensor_TFEEPtoROW_notation(double *t)
Function convert the symmetric double 3D tensor 't'.
void DeleteArray2D(bool **array, long d1)
Function deletes a 2D 'bool' array of dimension d1 x ??, allocated by new.
void giveInverseMatrix(double *mtrx, int n)
Function computes inversion of squared matrix mtrx.
void copy3Dto2Dtensors_FEEPreduced(const double *a, double *b)
Function copy the symmetric double 3D tensor 'a' to 2D tensor 'b'.
void giveInverseMatrix_core(double **answer, double **mtrx, int n, bool vect)
Function gives inversion of squared matrix mtrx.
double ** AllocateArray2D(long d1, long d2)
Operations with 2d, 3d, 4d arrays of various sizes.
void copyMatrix_1Dto2D(const double *v, double **m, long n)
Function copies 2D matrix saved in row-wise vector v[n * n] to 2d array m[n][n].
void CleanVector(double *a, long n)
Functin cleans a 'double' vector, initialize each value being 0-zero.
void CopyTensorAndReduceToFeep(const double *a, double *b)
Function copy two double tensor, 'a' -> 'b', saved as 9 component vectors.