FEMTIC
Util.h
Go to the documentation of this file.
1 //-------------------------------------------------------------------------------------------------------
2 // The MIT License (MIT)
3 //
4 // Copyright (c) 2021 Yoshiya Usui
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in all
14 // copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
23 //-------------------------------------------------------------------------------------------------------
24 #ifndef DBLDEF_UTIL
25 #define DBLDEF_UTIL
26 
27 #include <iostream>
28 #include <string>
29 #include <algorithm>
30 #include <complex>
31 
32 #include "CommonParameters.h"
33 
34 // Flag specifing comparative operators
36  EQUAL=0,
39 };
40 
41 // Sort elements by its key value with quick sort
42 void quickSort( const int numOfIDs, int* ids, const double* values );
43 
44 // Sort elements by values of its three keys with quick sort
45 void quickSortThreeKeys( const int numOfIDs, int* ids,
46  const double* firstKeyValues, const double* secondKeyValues, const double* thirdKeyValues );
47 
48 // Compare values by its three keys
49 int compareValueByThreeKeys( const int lhsID, const int rhsID, const double* firstKeyValues, const double* secondKeyValues, const double* thirdKeyValues );
50 
51 // Calculate matrix product for 2 x 2 double matrix
53 
54 // Calculate 3D vectors
56 
57 // Calculate outer product of 3D vectors
59 
60 // Calculate inner product of 3D vectors
62 
63 // Calculate impedance tensor component from apparent resisitivity and phase
64 void calcImpedanceTensorComponentFromApparentResistivityAndPhase( const double freq, const double appRes, const double appResError,
65  const double phase, const double phaseError,
66  std::complex<double>& Z, CommonParameters::DoubleComplexValues& ZError );
67 
68 #ifdef _ANISOTOROPY
69 void rotateTensor( double tensorRotated[3][3], const double rotationTensor[3][3] );
70 #endif
71 
72 #endif
void quickSortThreeKeys(const int numOfIDs, int *ids, const double *firstKeyValues, const double *secondKeyValues, const double *thirdKeyValues)
Definition: Util.cpp:145
void calcImpedanceTensorComponentFromApparentResistivityAndPhase(const double freq, const double appRes, const double appResError, const double phase, const double phaseError, std::complex< double > &Z, CommonParameters::DoubleComplexValues &ZError)
Definition: Util.cpp:336
double calcInnerProduct(const CommonParameters::Vector3D &vec1, const CommonParameters::Vector3D &vec2)
Definition: Util.cpp:329
CommonParameters::Vector3D calcVector3D(const CommonParameters::locationXYZ &startCoords, const CommonParameters::locationXYZ &endCoords)
Definition: Util.cpp:312
int compareValueByThreeKeys(const int lhsID, const int rhsID, const double *firstKeyValues, const double *secondKeyValues, const double *thirdKeyValues)
Definition: Util.cpp:262
void quickSort(const int numOfIDs, int *ids, const double *values)
Definition: Util.cpp:39
void calcProductFor2x2DoubleMatrix(const CommonParameters::DoubleMatrix2x2 &matInA, const CommonParameters::DoubleMatrix2x2 &matInB, CommonParameters::DoubleMatrix2x2 &matOut)
Definition: Util.cpp:296
CommonParameters::Vector3D calcOuterProduct(const CommonParameters::Vector3D &vec1, const CommonParameters::Vector3D &vec2)
Definition: Util.cpp:320
comparativeOperators
Definition: Util.h:35
@ LARGE_LEFT_HAND_SIDE
Definition: Util.h:37
@ EQUAL
Definition: Util.h:36
@ SMALL_LEFT_HAND_SIDE
Definition: Util.h:38
Definition: CommonParameters.h:64
Definition: CommonParameters.h:74
Definition: CommonParameters.h:93
Definition: CommonParameters.h:53