├── .gitignore ├── DruckerPrager_multi_yield_surface.cpp ├── DruckerPrager_multi_yield_surface.h ├── Makefile ├── MultiYieldSurfaceMaterial.cpp ├── MultiYieldSurfaceMaterial.h ├── Readme.md ├── Readme_theory.pdf ├── RoundedMohrCoulomb_multi_surface.cpp ├── RoundedMohrCoulomb_multi_surface.h ├── img ├── contact_condition.png ├── cyclic_behavior.png ├── multi-surface.png └── results.png ├── ltensor ├── Expr │ ├── Expr1 │ │ ├── Expr1.h │ │ ├── Expr1_Equals.h │ │ ├── Expr1_contract_Expr1.h │ │ ├── Expr1_divided_Expr0.h │ │ ├── Expr1_minus_Expr1.h │ │ ├── Expr1_plus_Expr1.h │ │ ├── Expr1_times_Expr0.h │ │ ├── Expr1s.h │ │ ├── F_Expr1.h │ │ ├── IndexedArray1.h │ │ ├── minus_Expr1.h │ │ └── plus_Expr1.h │ ├── Expr2 │ │ ├── Expr1_times_Expr1.h │ │ ├── Expr2.h │ │ ├── Expr2_Equals.h │ │ ├── Expr2_contract_Expr1.h │ │ ├── Expr2_contract_Expr2.h │ │ ├── Expr2_divided_Expr0.h │ │ ├── Expr2_minus_Expr2.h │ │ ├── Expr2_plus_Expr2.h │ │ ├── Expr2_times_Expr0.h │ │ ├── Expr2_times_Expr0a.h │ │ ├── Expr2s.h │ │ ├── F_Expr2.h │ │ ├── IndexedArray2.h │ │ ├── minus_Expr2.h │ │ └── plus_Expr2.h │ ├── Expr3 │ │ ├── Expr2_times_Expr1.h │ │ ├── Expr3.h │ │ ├── Expr3_Equals.h │ │ ├── Expr3_contract_Expr1.h │ │ ├── Expr3_contract_Expr2.h │ │ ├── Expr3_contract_Expr3.h │ │ ├── Expr3_divided_Expr0.h │ │ ├── Expr3_equals_Expr3.h │ │ ├── Expr3_minus_Expr3.h │ │ ├── Expr3_plus_Expr3.h │ │ ├── Expr3_times_Expr0.h │ │ ├── Expr3_to_Expr3permuted.h │ │ ├── Expr3s.h │ │ ├── F_Expr3.h │ │ ├── minus_Expr3.h │ │ └── plus_Expr3.h │ ├── Expr4 │ │ ├── Expr2_times_Expr2.h │ │ ├── Expr3_times_Expr1.h │ │ ├── Expr4.h │ │ ├── Expr4_Equals.h │ │ ├── Expr4_contract_Expr1.h │ │ ├── Expr4_contract_Expr2.h │ │ ├── Expr4_contract_Expr3.h │ │ ├── Expr4_contract_Expr4.h │ │ ├── Expr4_divided_Expr0.h │ │ ├── Expr4_equals_Expr4.h │ │ ├── Expr4_minus_Expr4.h │ │ ├── Expr4_plus_Expr4.h │ │ ├── Expr4_times_Expr0.h │ │ ├── Expr4s.h │ │ ├── F_Expr4.h │ │ ├── minus_Expr4.h │ │ └── plus_Expr4.h │ ├── Exprs.h │ ├── Index.h │ ├── IndexF.h │ ├── IndexG.h │ ├── IndexH.h │ ├── IndexH_bis.h │ └── Number.h ├── LTensor.cbp ├── LTensor.depend ├── LTensor.h ├── LTensor.sln ├── LTensor.vcproj ├── LTensor.vcxproj ├── LTensor.vcxproj.filters ├── Marray │ ├── Marray.h │ ├── Marray_rank1.h │ ├── Marray_rank2.h │ ├── Marray_rank3.h │ └── Marray_rank4.h ├── Promote_Types │ └── promote.h ├── Tensor_Operations │ ├── Encapsulate_Tensors │ │ ├── Encapsulate_Tensors.h │ │ ├── Encapsulate_to_Expr1.h │ │ ├── Encapsulate_to_Expr2.h │ │ ├── Encapsulate_to_Expr3.h │ │ └── Encapsulate_to_Expr4.h │ ├── Equate_Tensors │ │ ├── Equate_Tensors.h │ │ ├── Equate_TensorsRank1.h │ │ ├── Equate_TensorsRank2.h │ │ ├── Equate_TensorsRank3.h │ │ └── Equate_TensorsRank4.h │ ├── Minus_Tensors │ │ ├── Minus_Tensors.h │ │ ├── Minus_TensorsRank1.h │ │ ├── Minus_TensorsRank2.h │ │ ├── Minus_TensorsRank3.h │ │ └── Minus_TensorsRank4.h │ ├── Permute_Tensors │ │ ├── Permute_Tensors.h │ │ ├── Permute_TensorsRank2.h │ │ ├── Permute_TensorsRank3.h │ │ └── Permute_TensorsRank4.h │ ├── Plus_Tensors │ │ ├── Plus_Tensors.h │ │ ├── Plus_TensorsRank1.h │ │ ├── Plus_TensorsRank2.h │ │ ├── Plus_TensorsRank3.h │ │ └── Plus_TensorsRank4.h │ ├── Subtract_Tensors │ │ ├── Subtract_Tensors.h │ │ ├── Subtract_TensorsRank1.h │ │ ├── Subtract_TensorsRank2.h │ │ ├── Subtract_TensorsRank3.h │ │ └── Subtract_TensorsRank4.h │ ├── Sum_Tensors │ │ ├── Sum_Tensors.h │ │ ├── Sum_TensorsRank1.h │ │ ├── Sum_TensorsRank2.h │ │ ├── Sum_TensorsRank3.h │ │ └── Sum_TensorsRank4.h │ ├── Tensor_Contractions │ │ ├── Tensor1_contracts_Tensor1.h │ │ ├── Tensor2_contracts_Tensor1.h │ │ ├── Tensor2_contracts_Tensor2.h │ │ ├── Tensor3_contracts_Tensor1.h │ │ ├── Tensor3_contracts_Tensor2.h │ │ ├── Tensor3_contracts_Tensor3.h │ │ ├── Tensor3_contracts_itsindices.h │ │ ├── Tensor4_contracts_Tensor1.h │ │ ├── Tensor4_contracts_Tensor2.h │ │ ├── Tensor4_contracts_Tensor3.h │ │ ├── Tensor4_contracts_Tensor4.h │ │ ├── Tensor4_contracts_itsindices.h │ │ └── Tensor_Contractions.h │ ├── Tensor_Operations.h │ ├── Tensor_divided_Scalar │ │ ├── TensorRank1_divided_Scalar.h │ │ ├── TensorRank2_divided_Scalar.h │ │ ├── TensorRank3_divided_Scalar.h │ │ ├── TensorRank4_divided_Scalar.h │ │ └── Tensor_divided_Scalar.h │ ├── Tensor_times_Scalar │ │ ├── TensorRank1_times_Scalar.h │ │ ├── TensorRank2_times_Scalar.h │ │ ├── TensorRank3_times_Scalar.h │ │ ├── TensorRank4_times_Scalar.h │ │ └── Tensor_times_Scalar.h │ ├── Tensor_times_Tensor │ │ ├── Tensor1_times_Tensor1.h │ │ ├── Tensor2_times_Tensor1.h │ │ ├── Tensor2_times_Tensor2.h │ │ ├── Tensor3_times_Tensor1.h │ │ └── Tensor_times_Tensor.h │ └── check_Tensor_Operations.h ├── algorithms │ └── algorithms.h ├── apple.cpp ├── apple.h ├── base │ ├── Array_base.h │ ├── Constants.h │ ├── Range.h │ └── TinyArray_base.h ├── helper.h ├── main.cpp ├── meta │ └── Metaprograms.h ├── run_apple.cpp ├── static │ └── sVector.h ├── storage │ └── storage.h └── utils │ ├── cputimeprofiler.h │ └── timer.h ├── test_GUI_MYS_DP.py ├── test_GUI_MYS_RMC.py ├── test_MYS_RMC_equal_shear.cpp ├── test_multi_ys_DP_shear.cpp ├── test_multi_ys_shear.cpp ├── test_vonMises_multi_shear.py ├── vonMises_multi_surface.cpp └── vonMises_multi_surface.h /.gitignore: -------------------------------------------------------------------------------- 1 | **/*.o 2 | **/*.out 3 | **/*.html 4 | **/.depend 5 | 6 | 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | vm: 2 | g++ -o multi_ys_VM test_multi_ys_shear.cpp vonMises_multi_surface.cpp MultiYieldSurfaceMaterial.cpp -std=c++11 -Wall 3 | python3 test_vonMises_multi_shear.py 4 | 5 | dp: 6 | g++ -o multi_ys_DP test_multi_ys_DP_shear.cpp DruckerPrager_multi_yield_surface.cpp MultiYieldSurfaceMaterial.cpp -std=c++11 -Wall 7 | python3 test_GUI_MYS_DP.py 8 | 9 | 10 | 11 | rmc: 12 | g++ -o test_MYS_RMC_equal_shear test_MYS_RMC_equal_shear.cpp RoundedMohrCoulomb_multi_surface.cpp MultiYieldSurfaceMaterial.cpp -std=c++11 -Wall 13 | python3 test_GUI_MYS_RMC.py 14 | 15 | # compile: 16 | # g++ -o multi_ys_DP test_multi_ys_DP_shear.cpp DruckerPrager_multi_yield_surface.cpp -std=c++11 -Wall 17 | 18 | # plot: 19 | # python plot.py 20 | 21 | # GUI: 22 | # python test_GUI_MYS_DP.py 23 | 24 | clean: 25 | -rm -f multi_ys 26 | -rm -f strain_stress.txt 27 | -rm -f results.pdf -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | In order to simulate the realistic shear modulus behavior, multi-surface plastic model is proposed by Mroz and further developed by Prevost. Multi-surface material model is able to match the G/Gmax curves by piecewise linear curves. 4 | 5 | As the name implies, multi-surface model is composed of multiple yield surface in the deviatoric stress space. For each yield surface, the stress-strain curve is linear. The shear modulus becomes smaller after the stress states exceed each yield surface. 6 | 7 | The multi-surface material models are implemented with a simple python-based GUI for testing. 8 | 9 | #### Various Yield Surfaces 10 | 11 | Three yield surfaces were implemented for the multi-surface-material model. 12 | - von-Mises 13 | - Drucker-Prager 14 | - rounded-Mohr-Coulomb 15 | 16 | 17 | #### Illustration 18 | 19 | The mapping between multiple yield surfaces and the shear modulus reduction (G/Gmax): 20 | 21 | ![multi-surface](img/multi-surface.png) 22 | 23 | 24 | The contact between multiple yield surfaces (ensuring non-overlaps): 25 | 26 | ![contact_condition](img/contact_condition.png) 27 | 28 | 29 | The sample stress results and the modulus reduction results: 30 | 31 | ![results](img/results.png) 32 | 33 | 34 | 35 | The cyclic behaviors of the stress-strain results: 36 | 37 | ![cyclic_behavior](img/cyclic_behavior.png) 38 | 39 | #### Prerequisite: 40 | ```bash 41 | sudo apt install python-tk python3-matplotlib 42 | ``` 43 | 44 | #### Notes 45 | Tested on 46 | * g++-7.4.0 47 | * python 3.6.8 48 | 49 | #### Reference 50 | 51 | Prevost, Jean H. "A simple plasticity theory for frictional cohesionless soils." International Journal of Soil Dynamics and Earthquake Engineering 4, no. 1 (1985): 9-17. 52 | 53 | -------------------------------------------------------------------------------- /Readme_theory.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuan-feng/multi_surface_plasticity/f579059f0f5842fdc054c26132888c4d274bd6d2/Readme_theory.pdf -------------------------------------------------------------------------------- /img/contact_condition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuan-feng/multi_surface_plasticity/f579059f0f5842fdc054c26132888c4d274bd6d2/img/contact_condition.png -------------------------------------------------------------------------------- /img/cyclic_behavior.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuan-feng/multi_surface_plasticity/f579059f0f5842fdc054c26132888c4d274bd6d2/img/cyclic_behavior.png -------------------------------------------------------------------------------- /img/multi-surface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuan-feng/multi_surface_plasticity/f579059f0f5842fdc054c26132888c4d274bd6d2/img/multi-surface.png -------------------------------------------------------------------------------- /img/results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuan-feng/multi_surface_plasticity/f579059f0f5842fdc054c26132888c4d274bd6d2/img/results.png -------------------------------------------------------------------------------- /ltensor/Expr/Expr1/Expr1_Equals.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | 27 | #ifndef Expr1_Equals_H 28 | #define Expr1_Equals_H 29 | 30 | //#define CHECK_Expr1_Definitions 31 | //#define USE_ASSERT_Expr1 32 | #ifdef USE_ASSERT_Expr1 33 | #include 34 | #endif 35 | 36 | 37 | ////////////////////////////////////////////////////////////////////// 38 | // Definitions of Assignations of tensors such as T(i) = C(i) 39 | ////////////////////////////////////////////////////////////////////// 40 | 41 | 42 | template 43 | template 44 | inline Expr1 & 45 | Expr1::operator=(const Expr1 &rhs) 46 | { 47 | Li_equals_Ri((*this),rhs); 48 | return *this; 49 | } 50 | 51 | 52 | 53 | 54 | template 55 | inline Expr1 & 56 | Expr1::operator=(const Expr1 &rhs) 57 | { 58 | Li_equals_Ri((*this),rhs); 59 | return *this; 60 | } 61 | 62 | 63 | 64 | 65 | template 66 | template 67 | inline Expr1 & 68 | Expr1::operator+=(const Expr1 &rhs) 69 | { 70 | Li_plusequals_Ri((*this),rhs); 71 | return *this; 72 | } 73 | 74 | template 75 | template 76 | inline Expr1 & 77 | Expr1::operator-=(const Expr1 &rhs) 78 | { 79 | Li_minusequals_Ri((*this),rhs); 80 | return *this; 81 | } 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr1/Expr1_contract_Expr1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | /* Adds two Tensor1's together, yielding a Tensor1. */ 27 | #ifndef Expr1_contract_Expr1_H 28 | #define Expr1_contract_Expr1_H 29 | 30 | 31 | #define ExprAi Expr1 32 | #define ExprBi Expr1 33 | #define promotedType promote::V 34 | /*! \brief The operator that defines a contraction 35 | * 36 | * This operator performs the contraction along i index and returns the value 37 | * A(i)*B(i) 38 | */ 39 | template < class A, class B, class T, class U, char i > 40 | inline const typename promotedType 41 | operator* (const ExprAi &ExprL, const ExprBi &ExprR) 42 | { 43 | return Ai_contracts_Bi(ExprL,ExprR); 44 | } 45 | 46 | 47 | 48 | #undef ExprAi 49 | #undef ExprBi 50 | #undef promotedType 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr1/Expr1_divided_Expr0.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | 27 | /* Division of Tensor1 by a generic, yielding a Tensor1. 28 | Usually used for doubles, but could be used for complex, etc. All 29 | that it requires is that you can add an element of the Tensor1 to 30 | it. */ 31 | 32 | #ifndef Expr1_divided_Expr0_H 33 | #define Expr1_divided_Expr0_H 34 | 35 | #define ExprAi Expr1 36 | #define promotedType promote::V 37 | 38 | 39 | /*! \brief The operator that defines an Expr division by a scalar 40 | * 41 | * This operator performs the division on the whole i dimension 42 | */ 43 | 44 | 45 | template < class A, class T, class U, char i > 46 | inline const Expr1 < const Ai_divided_u < ExprAi, typename promotedType, U>, typename promotedType, i > 47 | operator/ (const ExprAi &a, const U & u0) 48 | { 49 | typedef const Ai_divided_u < ExprAi, typename promotedType, U> ExprObj; 50 | return Expr1 < ExprObj, typename promotedType, i > (ExprObj (a, u0)); 51 | } 52 | 53 | 54 | 55 | #undef ExprAi 56 | #undef promotedType 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr1/Expr1_minus_Expr1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | 27 | /* Adds two Tensor1's together, yielding a Tensor1. */ 28 | #ifndef Expr1_minus_Expr1_H 29 | #define Expr1_minus_Expr1_H 30 | 31 | 32 | //#define CHECK_Expr1_minus_Expr1 33 | //#define USE_ASSERT_Expr1 34 | #ifdef USE_ASSERT_Expr1 35 | #include 36 | #endif 37 | 38 | #include "./Expr1.h" 39 | 40 | #define ExprAi Expr1 41 | #define ExprBi Expr1 42 | #define PromotedType promote::V 43 | 44 | 45 | /*!\brief Minus operation between two Expr Objects of rank 1 46 | * 47 | * Performs the - operation and returns another Expr of rank 1 containing the result 48 | */ 49 | 50 | template < class A, class B, class T,class U, char i > 51 | inline const Expr1 < const Ai_minus_Bi < ExprAi,ExprBi , typename PromotedType >, typename PromotedType, i > 52 | operator- (const ExprAi &ExprL, const ExprBi &ExprR) 53 | { 54 | typedef const Ai_minus_Bi < ExprAi , ExprBi , typename PromotedType > Expr_Obj; 55 | return Expr1 < Expr_Obj, typename PromotedType , i > (Expr_Obj (ExprL, ExprR)); 56 | } 57 | 58 | #undef ExprAi 59 | #undef ExprBi 60 | #undef PromotedType 61 | #endif 62 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr1/Expr1_plus_Expr1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | 27 | /* Adds two Tensor1's together, yielding a Tensor1. */ 28 | #ifndef Expr1_plus_Expr1_H 29 | #define Expr1_plus_Expr1_H 30 | 31 | 32 | //#define CHECK_Expr1_plus_Expr1 33 | //#define USE_ASSERT_Expr1 34 | #ifdef USE_ASSERT_Expr1 35 | #include 36 | #endif 37 | 38 | #include "./Expr1.h" 39 | #include "../../Promote_Types/promote.h" 40 | 41 | #define ExprAi Expr1 42 | #define ExprBi Expr1 43 | #define promotedType promote::V 44 | 45 | /*!\brief Plus operation between two Expr Objects of rank 1 46 | * 47 | * Performs the + operation and returns another Expr of rank 1 containing the result 48 | */ 49 | 50 | template < class A, class B, class T,class U, char i > 51 | inline const Expr1 < const Ai_plus_Bi < ExprAi , ExprBi , typename promotedType >, typename promotedType, i > 52 | operator+ (const ExprAi &ExprL, const ExprBi &ExprR) 53 | { 54 | typedef const Ai_plus_Bi < ExprAi , ExprBi , typename promotedType > Expr_Obj; 55 | return Expr1 < Expr_Obj, typename promotedType , i > (Expr_Obj (ExprL, ExprR)); 56 | } 57 | 58 | 59 | 60 | #undef ExprAi 61 | #undef ExprBi 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr1/Expr1s.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #include "./Expr1.h" 27 | #include "./F_Expr1.h" 28 | #include "./Expr1_Equals.h" 29 | #include "./Expr1_plus_Expr1.h" 30 | #include "./Expr1_minus_Expr1.h" 31 | #include "./Expr1_times_Expr0.h" 32 | #include "./Expr1_divided_Expr0.h" 33 | #include "./minus_Expr1.h" 34 | #include "./plus_Expr1.h" 35 | #include "./Expr1_contract_Expr1.h" 36 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr1/IndexedArray1.h: -------------------------------------------------------------------------------- 1 | #ifndef INDEXEDARRAY1 2 | #define INDEXEDARRAY1 3 | 4 | template < class A, class T,char i,int indexed> 5 | class IndexedArray1 6 | { 7 | 8 | private: 9 | A a; 10 | 11 | 12 | public: 13 | const IndexF &index; 14 | 15 | ~IndexedArray1 () 16 | { 17 | 18 | } 19 | 20 | IndexedArray1(const A & arhs, const IndexF &idx): a(arhs),index(idx) 21 | 22 | { 23 | 24 | } 25 | 26 | T operator() (const int N) const 27 | { 28 | return a(index(N)); 29 | } 30 | 31 | T & operator()(const int N) 32 | { 33 | return a(index(N)); 34 | } 35 | 36 | int get_dim1 () const 37 | { 38 | return this->index.get_size(); 39 | } 40 | 41 | 42 | 43 | 44 | 45 | }; 46 | 47 | 48 | template < class A, class T,char i> 49 | class IndexedArray1 50 | { 51 | 52 | private: 53 | A &a; 54 | 55 | 56 | public: 57 | const IndexF &index; 58 | 59 | ~IndexedArray1 () 60 | { 61 | 62 | } 63 | 64 | IndexedArray1(A & arhs, const IndexF &idx): a(arhs),index(idx) 65 | 66 | { 67 | 68 | } 69 | 70 | inline T operator() (const int N) const 71 | { 72 | return a(index(N)); 73 | } 74 | 75 | inline T & operator()(const int N) 76 | { 77 | return a(index(N)); 78 | } 79 | 80 | int get_dim1 () const 81 | { 82 | return this->index.get_size(); 83 | } 84 | 85 | 86 | 87 | 88 | 89 | }; 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr1/minus_Expr1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | /* Declares a wrapper class for the unary minus (-) operator. */ 27 | #ifndef minus_Expr1_H 28 | #define minus_Expr1_H 29 | 30 | 31 | //#define CHECK_minus_Expr1 32 | //#define USE_ASSERT_Expr1 33 | #ifdef USE_ASSERT_Expr1 34 | #include 35 | #endif 36 | 37 | #define ExprAi Expr1 38 | 39 | template < class A, class T, char i> 40 | inline const Expr1 < const minus_Ai < ExprAi, T>, T, i> 41 | operator- (const ExprAi &a) 42 | { 43 | typedef const minus_Ai < ExprAi, T> ExprObj; 44 | return Expr1 < ExprObj, T, i > ( ExprObj(a) ); 45 | } 46 | 47 | #undef ExprAi 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr1/plus_Expr1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | /* Declares a wrapper class for the unary minus (-) operator. */ 27 | #ifndef plus_Expr1_H 28 | #define plus_Expr1_H 29 | 30 | 31 | 32 | //#define USE_ASSERT_Expr1 33 | #ifdef USE_ASSERT_Expr1 34 | #include 35 | #endif 36 | 37 | #define ExprAi Expr1 38 | 39 | template < class A, class T, char i> 40 | inline const Expr1 < const plus_Ai < ExprAi, T>, T, i> 41 | operator+ (const ExprAi &a) 42 | { 43 | typedef const plus_Ai < ExprAi, T> ExprObj; 44 | return Expr1 < ExprObj, T, i > ( ExprObj(a) ); 45 | } 46 | 47 | #undef ExprAi 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr2/Expr1_times_Expr1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | 27 | #ifndef Expr1_times_Expr1_H 28 | #define Expr1_times_Expr1_H 29 | 30 | #define ExprAi Expr1 31 | #define ExprBj Expr1 32 | #define promotedType promote::V 33 | 34 | 35 | //////////////////////////////////////////// 36 | /*!brief A(i) * B(j) -> C(i,j) */ 37 | /////////////////////////////////////////// 38 | 39 | /*\brief Product operation between two Expr of rank 1 with different indexes 40 | * 41 | * Performs the * operation and returns an Expr of Rank 2 with the result 42 | * A(i) * B(j) -> C(i,j) 43 | */ 44 | 45 | template < class A, class B, class T, class U, char i , char j> 46 | inline const Expr2 < const Ai_times_Bj < ExprAi, typename promotedType, ExprBj>, typename promotedType, i, j > 47 | operator* (const ExprAi &a, const ExprBj &b) 48 | { 49 | typedef const Ai_times_Bj< ExprAi, typename promotedType, ExprBj > ExprObj; 50 | return Expr2 < ExprObj, typename promotedType, i, j> (ExprObj (a,b)); 51 | } 52 | 53 | 54 | #undef ExprAi 55 | #undef ExprBj 56 | #undef pType 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr2/Expr2_divided_Expr0.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | /* Division of a Tensor2 by a generic, yielding a Tensor2. 27 | Usually used for doubles, but could be used for complex, etc. All 28 | that it requires is that you can add an element of the Tensor1 to 29 | it. */ 30 | 31 | #ifndef Expr2_divided_Expr0_H 32 | #define Expr2_divided_Expr0_H 33 | 34 | //#define CHECK_Expr2_divided_Expr0 35 | 36 | 37 | /*! \brief The operator that defines an Expr division by a scalar 38 | * 39 | * This operator performs the division on the whole (i,j) dimension 40 | * A(i,j) / u0 -> Tensor2 41 | */ 42 | 43 | #define ExprAij Expr2 44 | #define promotedType promote::V 45 | 46 | template < class A, class T, class U, char i, char j > 47 | inline const Expr2 < const Aij_divided_u < ExprAij, typename promotedType, U>, typename promotedType, i, j > 48 | operator/ (const ExprAij &a, const U & u0) 49 | { 50 | typedef const Aij_divided_u < ExprAij, typename promotedType, U> ExprObj; 51 | return Expr2 < ExprObj, typename promotedType,i,j > (ExprObj (a, u0)); 52 | } 53 | 54 | 55 | #undef ExprAij 56 | #undef promotedType 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr2/Expr2_times_Expr0a.h: -------------------------------------------------------------------------------- 1 | /* Multipliess a Tensor1 by a generic (or vice versa), yielding a Tensor1. 2 | Usually used for doubles, but could be used for complex, etc. All 3 | that it requires is that you can add an element of the Tensor1 to 4 | it. */ 5 | 6 | #ifndef Expr2_times_Expr0_H 7 | #define Expr2_times_Expr0_H 8 | 9 | //#define CHECK_Expr2_times_Expr0 10 | 11 | /* A(i) * d0 -> Tensor1 */ 12 | 13 | template < class A, class T, class U, char i > class Expr2_times_Expr0 14 | { 15 | const Expr2 < A, T, i > iterA; 16 | const U d; 17 | public: 18 | const int dim1; 19 | 20 | Expr2_times_Expr0 (const Expr2 < A, T, i > &a, const U & d0): 21 | iterA(a), d(d0),dim1(a.get_dim1()) 22 | { 23 | } 24 | 25 | typename promote < T, U >::V operator () (const int N) const 26 | { 27 | return iterA (N) * d; 28 | } 29 | 30 | int get_dim1 () const 31 | { 32 | return dim1; 33 | } 34 | 35 | }; 36 | 37 | template < class A, class T, class U, char i > 38 | inline const Expr2 < const Expr2_times_Expr0 < A, T, U, i >, 39 | typename promote < T, U >::V, i > 40 | operator* (const Expr2 < A, T, i > &a, const U & d0) 41 | { 42 | typedef const Expr2_times_Expr0 < A, T, U, i > ExprObj; 43 | return Expr2 < ExprObj, typename promote < T, U >::V,i > (ExprObj (a, d0)); 44 | } 45 | 46 | /* d0 * A(i) -> Tensor1 */ 47 | 48 | template < class A, class T, class U, char i > 49 | inline const Expr2 < const Expr2_times_Expr0 < A, T, U, i >, 50 | typename promote < T, U >::V, i > 51 | operator* (const U & d0, const Expr2 < A, T, i > &a) 52 | { 53 | typedef const Expr2_times_Expr0 < A, T, U, i > ExprObj; 54 | return Expr2 < ExprObj, typename promote < T, U >::V,i > (ExprObj (a, d0)); 55 | } 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr2/Expr2s.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #include "./Expr2.h" 27 | #include "./F_Expr2.h" 28 | #include "./Expr2_Equals.h" 29 | //#include "./Expr2_equals_Expr2.h" 30 | #include "./Expr2_plus_Expr2.h" 31 | #include "./Expr2_minus_Expr2.h" 32 | #include "./Expr2_times_Expr0.h" 33 | #include "./Expr2_divided_Expr0.h" 34 | #include "./minus_Expr2.h" 35 | #include "./plus_Expr2.h" 36 | #include "./Expr2_contract_Expr2.h" 37 | #include "./Expr2_contract_Expr1.h" 38 | #include "./Expr1_times_Expr1.h" 39 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr2/minus_Expr2.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | /* Declares a wrapper class for the unary minus (+) operator. */ 27 | #ifndef minus_Expr2_H 28 | #define minus_Expr2_H 29 | 30 | 31 | //#define CHECK_minus_Expr2 32 | 33 | //#define USE_ASSERT_Expr2 34 | #ifdef USE_ASSERT_Expr2 35 | #include 36 | #endif 37 | 38 | #define ExprAij Expr2 39 | 40 | template < class A, class T, char i , char j> 41 | inline const Expr2 < const minus_Aij < ExprAij, T>, T, i, j > 42 | operator- (const ExprAij &a) 43 | { 44 | typedef const minus_Aij < ExprAij, T> ExprObj; 45 | return Expr2 < ExprObj, T, i, j > ( ExprObj(a) ); 46 | } 47 | 48 | #undef ExprAij 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr2/plus_Expr2.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | /* Declares a wrapper class for the unary plus (+) operator. */ 27 | #ifndef plus_Expr2_H 28 | #define plus_Expr2_H 29 | 30 | 31 | //#define CHECK_plus_Expr2 32 | 33 | //#define USE_ASSERT_Expr2 34 | #ifdef USE_ASSERT_Expr2 35 | #include 36 | #endif 37 | 38 | #define ExprAij Expr2 39 | 40 | template < class A, class T, char i , char j> 41 | inline const Expr2 < const plus_Aij < ExprAij, T>, T, i, j > 42 | operator+ (const ExprAij &a) 43 | { 44 | typedef const plus_Aij < ExprAij, T> ExprObj; 45 | return Expr2 < ExprObj, T, i, j > ( ExprObj(a) ); 46 | } 47 | 48 | #undef ExprAij 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr3/Expr3_divided_Expr0.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | 27 | #ifndef Expr3_divided_Expr0_H 28 | #define Expr3_divided_Expr0_H 29 | 30 | #define ExprAijk Expr3 31 | #define promotedType promote::V 32 | 33 | 34 | /*! \brief The operator that defines an Expr division by a scalar 35 | * 36 | * This operator performs the division on the whole (i,j,k) dimension 37 | * A(i,j,k) / u0 -> Tensor3 38 | */ 39 | 40 | template < class A, class T, class U, char i , char j, char k> 41 | inline const Expr3 < const Aijk_divided_u < ExprAijk, typename promotedType, U>, 42 | typename promotedType, i, j, k > 43 | operator/ (const ExprAijk &a, const U & u0) 44 | { 45 | typedef const Aijk_divided_u < ExprAijk, typename promotedType, U> ExprObj; 46 | return Expr3 < ExprObj, typename promotedType , i, j, k > (ExprObj (a, u0)); 47 | } 48 | 49 | 50 | #undef ExprAijk 51 | #undef pType 52 | #endif 53 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr3/Expr3_equals_Expr3.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////// 2 | // Define FUNCTIONS to perform operations of type: 3 | // Expr2 = Expr2 4 | ////////////////////////////////////////////////////////// 5 | #ifndef Expr2_equals_Expr2_H 6 | #define Expr2_equals_Expr2_H 7 | 8 | 9 | template 10 | inline void Expr2_equals_Expr2(Expr2 & TLeft, const Expr2 TRight) 11 | { 12 | #ifdef USE_ASSERT_Expr2 13 | assert ( TLeft.get_dim1() == TRight.get_dim1() ); 14 | assert ( TLeft.get_dim2() == TRight.get_dim2() ); 15 | #endif 16 | const int dim1 = TLeft.get_dim1(); 17 | const int dim2 = TLeft.get_dim2(); 18 | int n1; 19 | int n2; 20 | for(n1 = 0; n1 30 | inline void Expr2_plusequals_Expr2(Expr2 & TLeft, const Expr2 TRight) 31 | { 32 | #ifdef USE_ASSERT_Expr2 33 | assert ( TLeft.get_dim1() == TRight.get_dim1() ); 34 | assert ( TLeft.get_dim2() == TRight.get_dim2() ); 35 | #endif 36 | const int dim1 = TLeft.get_dim1(); 37 | const int dim2 = TLeft.get_dim2(); 38 | int n1; 39 | int n2; 40 | for(n1 = 0; n1 50 | inline void Expr2_minusequals_Expr2(Expr2 & TLeft, const Expr2 TRight) 51 | { 52 | #ifdef USE_ASSERT_Expr2 53 | assert ( TLeft.get_dim1() == TRight.get_dim1() ); 54 | assert ( TLeft.get_dim2() == TRight.get_dim2() ); 55 | #endif 56 | const int dim1 = TLeft.get_dim1(); 57 | const int dim2 = TLeft.get_dim2(); 58 | int n1; 59 | int n2; 60 | for(n1 = 0; n1 14 | class Expr3ji_to_Expr3ij 15 | { 16 | const Expr2 < A, T, j, i > TA; 17 | public: 18 | 19 | Expr2ji_to_Expr2ij (const Expr2 < A, T, j, i > &a): 20 | TA(a) 21 | { 22 | } 23 | 24 | int get_dim1 () const 25 | { 26 | return TA.get_dim2(); 27 | } 28 | 29 | int get_dim2 () const 30 | { 31 | return TA.get_dim1(); 32 | } 33 | 34 | T operator () (const int N1,const int N2) const 35 | { 36 | return TA(N2,N1); 37 | } 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr3/Expr3s.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #include "./Expr3.h" 27 | #include "./F_Expr3.h" 28 | #include "./Expr3_Equals.h" 29 | #include "./Expr3_plus_Expr3.h" 30 | #include "./Expr3_minus_Expr3.h" 31 | #include "./Expr3_times_Expr0.h" 32 | #include "./Expr3_divided_Expr0.h" 33 | #include "./minus_Expr3.h" 34 | #include "./plus_Expr3.h" 35 | #include "./Expr3_contract_Expr3.h" 36 | #include "./Expr3_contract_Expr1.h" 37 | #include "./Expr3_contract_Expr2.h" 38 | #include "./Expr2_times_Expr1.h" 39 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr3/minus_Expr3.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef minus_Expr3_H 27 | #define minus_Expr3_H 28 | 29 | #define ExprAijk Expr3 30 | 31 | template < class A, class T, char i , char j, char k> 32 | inline const Expr3 < const minus_Aijk < ExprAijk, T>, T, i, j, k > 33 | operator- (const ExprAijk &a) 34 | { 35 | typedef const minus_Aijk < ExprAijk, T> ExprObj; 36 | return Expr3 < ExprObj, T, i, j,k > ( ExprObj(a) ); 37 | } 38 | 39 | #undef ExprAijk 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr3/plus_Expr3.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef plus_Expr3_H 27 | #define plus_Expr3_H 28 | 29 | #define ExprAijk Expr3 30 | 31 | template < class A, class T, char i , char j, char k> 32 | inline const Expr3 < const plus_Aijk < ExprAijk, T>, T, i, j, k > 33 | operator+ (const ExprAijk &a) 34 | { 35 | typedef const plus_Aijk < ExprAijk, T> ExprObj; 36 | return Expr3 < ExprObj, T, i, j,k > ( ExprObj(a) ); 37 | } 38 | 39 | #undef ExprAijk 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr4/Expr2_times_Expr2.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | 27 | #ifndef Expr2_times_Expr2_H 28 | #define Expr2_times_Expr2_H 29 | 30 | #define ExprAij Expr2 31 | #define ExprBkl Expr2 32 | #define promotedType promote::V 33 | 34 | 35 | 36 | 37 | /*!\brief Product operation between two Expr of rank 2 38 | * 39 | * Performs the * operation and returns an Expr of rank 4 containing the result 40 | * A(i,j) * B(k,l) -> C(i,j,k.l) 41 | */ 42 | 43 | 44 | template < class A, class B, class T, class U, char i , char j, char k, char l> 45 | inline const Expr4 < const Aij_times_Bkl < ExprAij, typename promotedType, ExprBkl>, typename promotedType, i, j, k, l > 46 | operator* (const ExprAij &a, const ExprBkl &b) 47 | { 48 | typedef const Aij_times_Bkl< ExprAij, typename promotedType, ExprBkl > ExprObj; 49 | return Expr4 < ExprObj, typename promotedType, i, j, k,l> (ExprObj (a,b)); 50 | } 51 | 52 | 53 | 54 | #undef ExprAij 55 | #undef ExprBkl 56 | #undef pType 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr4/Expr4_divided_Expr0.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | 27 | #ifndef Expr4_divided_Expr0_H 28 | #define Expr4_divided_Expr0_H 29 | 30 | #define ExprAijkl Expr4 31 | #define promotedType promote::V 32 | 33 | // Define: 34 | // A(i,j,k,l) / u0 -> Tensor4 35 | 36 | 37 | template < class A, class T, class U, char i , char j, char k, char l> 38 | inline const Expr4 < const Aijkl_divided_u < ExprAijkl, typename promotedType, U>, 39 | typename promotedType, i, j, k, l> 40 | operator/ (const ExprAijkl &a, const U & u0) 41 | { 42 | typedef const Aijkl_divided_u < ExprAijkl, typename promotedType, U> ExprObj; 43 | return Expr4 < ExprObj, typename promotedType, i, j, k, l> (ExprObj (a, u0)); 44 | } 45 | 46 | 47 | #undef ExprAijkl 48 | #undef promotedType 49 | #endif 50 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr4/Expr4_times_Expr0.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | 27 | #ifndef Expr4_times_Expr0_H 28 | #define Expr4_times_Expr0_H 29 | 30 | #define ExprAijkl Expr4 31 | #define promotedType promote::V 32 | 33 | // Define: 34 | // A(i,j,k,l) * u0 -> Tensor4 35 | 36 | 37 | template < class A, class T, class U, char i , char j, char k, char l> 38 | inline const Expr4 < const Aijkl_times_u < ExprAijkl, typename promotedType, U>, 39 | typename promotedType, i, j, k, l > 40 | operator* (const ExprAijkl &a, const U & u0) 41 | { 42 | typedef const Aijkl_times_u < ExprAijkl, typename promotedType, U> ExprObj; 43 | return Expr4 < ExprObj, typename promotedType, i, j, k, l > (ExprObj (a, u0)); 44 | } 45 | 46 | // Define 47 | // u0 * A(i,j,k,l) -> Tensor4 48 | 49 | template < class A, class T, class U, char i , char j, char k, char l> 50 | inline const Expr4 < const Aijkl_times_u < ExprAijkl, typename promotedType, U>, 51 | typename promotedType, i, j, k, l > 52 | operator* ( const U & u0, const ExprAijkl &a) 53 | { 54 | typedef const Aijkl_times_u < ExprAijkl, typename promotedType, U> ExprObj; 55 | return Expr4 < ExprObj, typename promotedType, i, j, k, l > (ExprObj (a, u0)); 56 | } 57 | 58 | #undef ExprAijk 59 | #undef promotedType 60 | #endif 61 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr4/Expr4s.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #include "./Expr4.h" 27 | #include "./F_Expr4.h" 28 | #include "./Expr4_Equals.h" 29 | #include "./Expr4_plus_Expr4.h" 30 | #include "./Expr4_minus_Expr4.h" 31 | #include "./Expr4_times_Expr0.h" 32 | #include "./Expr4_divided_Expr0.h" 33 | #include "./minus_Expr4.h" 34 | #include "./plus_Expr4.h" 35 | #include "./Expr4_contract_Expr2.h" 36 | #include "./Expr4_contract_Expr1.h" 37 | #include "./Expr4_contract_Expr3.h" 38 | #include "./Expr4_contract_Expr4.h" 39 | #include "./Expr2_times_Expr2.h" 40 | #include "./Expr3_times_Expr1.h" 41 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr4/minus_Expr4.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef minus_Expr4_H 27 | #define minus_Expr4_H 28 | 29 | #define ExprAijkl Expr4 30 | 31 | template < class A, class T, char i , char j, char k, char l> 32 | inline const Expr4 < const minus_Aijkl < ExprAijkl, T>, T, i, j, k, l > 33 | operator- (const ExprAijkl &a) 34 | { 35 | typedef const minus_Aijkl < ExprAijkl, T> ExprObj; 36 | return Expr4 < ExprObj, T, i, j, k, l > ( ExprObj(a) ); 37 | } 38 | 39 | #undef ExprAijkl 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /ltensor/Expr/Expr4/plus_Expr4.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef plus_Expr4_H 27 | #define plus_Expr4_H 28 | 29 | #define ExprAijkl Expr4 30 | 31 | template < class A, class T, char i , char j, char k, char l> 32 | inline const Expr4 < const plus_Aijkl < ExprAijkl, T>, T, i, j, k, l> 33 | operator+ (const ExprAijkl &a) 34 | { 35 | typedef const plus_Aijkl < ExprAijkl, T> ExprObj; 36 | return Expr4 < ExprObj, T, i, j, k, l > ( ExprObj(a) ); 37 | } 38 | 39 | #undef ExprAijkl 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /ltensor/Expr/Exprs.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #include "./Expr1/Expr1s.h" 27 | #include "./Expr2/Expr2s.h" 28 | #include "./Expr3/Expr3s.h" 29 | #include "./Expr4/Expr4s.h" 30 | -------------------------------------------------------------------------------- /ltensor/Expr/Index.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Index_H 27 | #define Index_H 28 | 29 | 30 | enum IndexType { 31 | WHOLE = 1, 32 | SPECIFIC = 2 33 | }; 34 | 35 | template < char i , int Type=1 > 36 | class Index 37 | { 38 | 39 | 40 | 41 | }; 42 | 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /ltensor/Expr/IndexG.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef IndexG_H 27 | #define IndexG_H 28 | 29 | //specialization for indexG 30 | 31 | template < char i > 32 | class Index 33 | { 34 | 35 | 36 | public: 37 | int size; 38 | inline int operator()(int n){ 39 | return n; 40 | } 41 | 42 | inline int operator()(int n)const { 43 | return n; 44 | } 45 | 46 | template 47 | inline int get_dim1(const A &contenedor)const{ 48 | return contenedor.get_dim1(); 49 | } 50 | 51 | template 52 | inline int get_dim2(const A &contenedor)const{ 53 | return contenedor.get_dim2(); 54 | } 55 | 56 | template 57 | inline int get_dim3(const A &contenedor)const{ 58 | return contenedor.get_dim3(); 59 | } 60 | 61 | template 62 | inline int get_dim4(const A &contenedor)const{ 63 | return contenedor.get_dim4(); 64 | } 65 | 66 | 67 | 68 | }; 69 | 70 | 71 | 72 | 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /ltensor/Expr/IndexH.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef IndexH_H 27 | #define IndexH_H 28 | 29 | #include 30 | #include "../Marray/Marray_rank1.h" 31 | 32 | template 33 | class Index 34 | { 35 | 36 | 37 | public: 38 | 39 | Marray > indexes; 40 | 41 | Index(); 42 | 43 | 44 | Index(const Index &idx); 45 | 46 | 47 | Index(Marray idxs); 48 | Index(int* idxs,int n); 49 | Index(int init,int end,int stride=1); 50 | 51 | Index(int size); 52 | ~Index(); 53 | int get_dim1() const; 54 | int get_size()const; 55 | 56 | //weird index formulation 57 | 58 | void rebuild(int init,int end, int stride=1); 59 | inline int operator() (const int N) const; 60 | 61 | inline int & operator()(const int N); 62 | 63 | template 64 | Index & operator=(const Marray &idxs); 65 | 66 | void showIndexes(); 67 | 68 | 69 | friend std::ostream & operator<< (std::ostream & os, const Index & p) 70 | { 71 | std::cout << "IndexH = " << p.indexes; 72 | return os; 73 | } 74 | template 75 | inline int get_dim1(const A &contenedor) const; 76 | template 77 | inline int get_dim2(const A &contenedor) const; 78 | template 79 | inline int get_dim3(const A &contenedor) const; 80 | template 81 | inline int get_dim4(const A &contenedor) const; 82 | 83 | 84 | }; 85 | 86 | 87 | #include "IndexH_bis.h" 88 | 89 | #endif 90 | 91 | -------------------------------------------------------------------------------- /ltensor/Expr/Number.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | /* This index class allows you to explicitly use a part of a tensor. 27 | If you want to explicitly list all of the indices, just use 28 | int's. The usual way to do this is to declare a Number like 29 | 30 | Number<0> N; */ 31 | #ifndef Number_H 32 | #define Number_H 33 | template 34 | class Number 35 | { 36 | public: 37 | Number() {}; 38 | operator int() const 39 | { 40 | return N; 41 | } 42 | }; 43 | #endif 44 | -------------------------------------------------------------------------------- /ltensor/LTensor.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifdef MSVC 27 | #define __restrict__ __restrict 28 | #endif 29 | 30 | 31 | 32 | #include "./base/Array_base.h" 33 | #include "./base/TinyArray_base.h" 34 | #include "./Promote_Types/promote.h" 35 | #include "./Marray/Marray.h" 36 | #include "./Tensor_Operations/Tensor_Operations.h" 37 | #include "./Expr/Exprs.h" 38 | 39 | 40 | typedef Marray DTensor1; 41 | typedef Marray DTensor2; 42 | typedef Marray DTensor3; 43 | typedef Marray DTensor4; 44 | typedef Marray ITensor1; 45 | typedef Marray ITensor2; 46 | typedef Marray ITensor3; 47 | typedef Marray ITensor4; 48 | typedef Marray FTensor1; 49 | typedef Marray FTensor2; 50 | typedef Marray FTensor3; 51 | typedef Marray FTensor4; 52 | 53 | 54 | -------------------------------------------------------------------------------- /ltensor/LTensor.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LTensor", "LTensor.vcxproj", "{75F1C8A8-F2B1-40F2-9ED3-373DDCD11D50}" 5 | EndProject 6 | Global 7 | GlobalSection(SubversionScc) = preSolution 8 | Svn-Managed = True 9 | Manager = AnkhSVN - Subversion Support for Visual Studio 10 | EndGlobalSection 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Win32 = Debug|Win32 13 | Release|Win32 = Release|Win32 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {75F1C8A8-F2B1-40F2-9ED3-373DDCD11D50}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {75F1C8A8-F2B1-40F2-9ED3-373DDCD11D50}.Debug|Win32.Build.0 = Debug|Win32 18 | {75F1C8A8-F2B1-40F2-9ED3-373DDCD11D50}.Release|Win32.ActiveCfg = Release|Win32 19 | {75F1C8A8-F2B1-40F2-9ED3-373DDCD11D50}.Release|Win32.Build.0 = Release|Win32 20 | EndGlobalSection 21 | GlobalSection(SolutionProperties) = preSolution 22 | HideSolutionNode = FALSE 23 | EndGlobalSection 24 | EndGlobal 25 | -------------------------------------------------------------------------------- /ltensor/Marray/Marray.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | // -*- c++ -*- 27 | #ifndef Marray_H 28 | #define Marray_H 29 | 30 | #ifndef InheritedBase 31 | #define InheritedBase TinyArray_base 32 | #endif 33 | 34 | #include "../meta/Metaprograms.h" 35 | #include "../base/Array_base.h" 36 | 37 | template 38 | class Index; 39 | 40 | class IndexF; 41 | 42 | 43 | template < class T, int rank ,class base=InheritedBase > class Marray ; 44 | 45 | 46 | 47 | #include "../Expr/Index.h" 48 | #include "../Expr/IndexF.h" 49 | #include "../Expr/IndexH.h" 50 | #include "../Expr/IndexG.h" 51 | #include "./Marray_rank1.h" 52 | #include "./Marray_rank2.h" 53 | #include "./Marray_rank3.h" 54 | #include "./Marray_rank4.h" 55 | 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Encapsulate_Tensors/Encapsulate_Tensors.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #include "./Encapsulate_to_Expr1.h" 27 | #include "./Encapsulate_to_Expr2.h" 28 | #include "./Encapsulate_to_Expr3.h" 29 | #include "./Encapsulate_to_Expr4.h" 30 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Equate_Tensors/Equate_Tensors.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #include "./Equate_TensorsRank1.h" 27 | #include "./Equate_TensorsRank2.h" 28 | #include "./Equate_TensorsRank3.h" 29 | #include "./Equate_TensorsRank4.h" 30 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Minus_Tensors/Minus_Tensors.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Minus_Tensors_H 27 | #define Minus_Tensors_H 28 | 29 | #include "./Minus_TensorsRank1.h" 30 | #include "./Minus_TensorsRank2.h" 31 | #include "./Minus_TensorsRank3.h" 32 | #include "./Minus_TensorsRank4.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Minus_Tensors/Minus_TensorsRank1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Minus_TensorsRank1_H 27 | #define Minus_TensorsRank1_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define Minus = -A(i) 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T> 35 | class minus_Ai 36 | { 37 | 38 | private: 39 | 40 | const A objA; 41 | 42 | public: 43 | 44 | ~minus_Ai(){ } 45 | 46 | minus_Ai (const A &a) : objA(a){ } 47 | 48 | T operator () (const int N1) const 49 | { 50 | return -objA (N1); 51 | } 52 | 53 | int get_dim1() const 54 | { 55 | return objA.get_dim1(); 56 | } 57 | 58 | friend std::ostream & operator<< (std::ostream & os, const minus_Ai & v) 59 | { 60 | os << std::endl << "BEGIN:minus_Ai =" << &v << std::endl 61 | << ", A = "<< (v.objA) 62 | << "END.minus_Ai " << std::endl; 63 | return os; 64 | } 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Minus_Tensors/Minus_TensorsRank2.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Minus_TensorsRank2_H 27 | #define Minus_TensorsRank2_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define Minus = -A(i,j) 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T> 35 | class minus_Aij 36 | { 37 | 38 | private: 39 | 40 | const A objA; 41 | 42 | public: 43 | 44 | ~minus_Aij(){ } 45 | 46 | minus_Aij (const A &a) : objA(a) { } 47 | 48 | T operator () (const int N1,const int N2) const 49 | { 50 | return -objA (N1,N2); 51 | } 52 | 53 | int get_dim1() const 54 | { 55 | return objA.get_dim1(); 56 | } 57 | 58 | int get_dim2() const 59 | { 60 | return objA.get_dim2(); 61 | } 62 | 63 | friend std::ostream & operator<< (std::ostream & os, const minus_Aij & v) 64 | { 65 | os << std::endl << "BEGIN:minus_Aij =" << &v << std::endl 66 | << ", A = "<< (v.objA) 67 | << "END.minus_Aij " << std::endl; 68 | return os; 69 | } 70 | }; 71 | 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Minus_Tensors/Minus_TensorsRank3.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Minus_TensorsRank3_H 27 | #define Minus_TensorsRank3_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define Minus = -A(i,j,k) 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T> 35 | class minus_Aijk 36 | { 37 | 38 | private: 39 | 40 | const A objA; 41 | 42 | public: 43 | 44 | ~minus_Aijk(){ } 45 | 46 | minus_Aijk (const A &a) : objA(a) { } 47 | 48 | T operator () (const int N1,const int N2,const int N3) const 49 | { 50 | return -objA(N1,N2,N3); 51 | } 52 | 53 | int get_dim1() const 54 | { 55 | return objA.get_dim1(); 56 | } 57 | 58 | int get_dim2() const 59 | { 60 | return objA.get_dim2(); 61 | } 62 | 63 | int get_dim3() const 64 | { 65 | return objA.get_dim3(); 66 | } 67 | 68 | friend std::ostream & operator<< (std::ostream & os, const minus_Aijk & v) 69 | { 70 | os << std::endl << "BEGIN:minus_Aijk =" << &v << std::endl 71 | << ", A = "<< (v.objA) 72 | << "END.minus_Aijk " << std::endl; 73 | return os; 74 | } 75 | }; 76 | 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Minus_Tensors/Minus_TensorsRank4.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Minus_TensorsRank4_H 27 | #define Minus_TensorsRank4_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define Minus = +A(i,j,k,l) 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T> 35 | class minus_Aijkl 36 | { 37 | 38 | private: 39 | 40 | const A objA; 41 | 42 | public: 43 | 44 | ~minus_Aijkl(){ } 45 | 46 | minus_Aijkl (const A &a) : objA(a) { } 47 | 48 | T operator () (const int N1,const int N2,const int N3,const int N4) const 49 | { 50 | return -objA (N1,N2,N3,N4); 51 | } 52 | 53 | int get_dim1() const 54 | { 55 | return objA.get_dim1(); 56 | } 57 | 58 | int get_dim2() const 59 | { 60 | return objA.get_dim2(); 61 | } 62 | 63 | int get_dim3() const 64 | { 65 | return objA.get_dim3(); 66 | } 67 | 68 | int get_dim4() const 69 | { 70 | return objA.get_dim4(); 71 | } 72 | 73 | friend std::ostream & operator<< (std::ostream & os, const minus_Aijkl & v) 74 | { 75 | os << std::endl << "BEGIN:minus_Aijkl =" << &v << std::endl 76 | << ", A = "<< (v.objA) 77 | << "END.minus_Aijkl " << std::endl; 78 | return os; 79 | } 80 | }; 81 | 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Permute_Tensors/Permute_Tensors.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #include "./Permute_TensorsRank2.h" 27 | #include "./Permute_TensorsRank3.h" 28 | #include "./Permute_TensorsRank4.h" 29 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Permute_Tensors/Permute_TensorsRank2.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | ///////////////////////////////////////////////////// 27 | // Given Expr2=A(j,i) define a new permuted Expr2 P object 28 | // so to define: B(i,j)=A(j,i) 29 | ///////////////////////////////////////////////////// 30 | 31 | #ifndef Permute_TensorsRank2_H 32 | #define Permute_TensorsRank2_H 33 | 34 | //////////////////////////////////////////// 35 | // Define B(i,j)=A(i,j) ==> No permutation 36 | /////////////////////////////////////////// 37 | 38 | template < class A, class T> 39 | class Aij_to_Aij 40 | { 41 | A TA; 42 | public: 43 | 44 | Aij_to_Aij (const A &a): TA(a) 45 | { 46 | } 47 | 48 | int get_dim1 () const 49 | { 50 | return TA.get_dim1(); 51 | } 52 | 53 | int get_dim2 () const 54 | { 55 | return TA.get_dim2(); 56 | } 57 | 58 | T operator () (const int N1,const int N2) const 59 | { 60 | return TA(N1,N2); 61 | } 62 | }; 63 | 64 | //////////////////////////////////////////// 65 | // Define B(i,j)=A(j,i) 66 | /////////////////////////////////////////// 67 | 68 | 69 | template < class A, class T> 70 | class Aji_to_Aij 71 | { 72 | A TA; 73 | public: 74 | 75 | Aji_to_Aij (const A &a): TA(a) 76 | { 77 | } 78 | 79 | int get_dim1 () const 80 | { 81 | return TA.get_dim2(); 82 | } 83 | 84 | int get_dim2 () const 85 | { 86 | return TA.get_dim1(); 87 | } 88 | 89 | T operator () (const int N1,const int N2) const 90 | { 91 | return TA(N2,N1); 92 | } 93 | }; 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Plus_Tensors/Plus_Tensors.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Plus_Tensors_H 27 | #define Plus_Tensors_H 28 | 29 | #include "./Plus_TensorsRank1.h" 30 | #include "./Plus_TensorsRank2.h" 31 | #include "./Plus_TensorsRank3.h" 32 | #include "./Plus_TensorsRank4.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Plus_Tensors/Plus_TensorsRank1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Plus_TensorsRank1_H 27 | #define Plus_TensorsRank1_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define PLUS = +A(i) 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T> 35 | class plus_Ai 36 | { 37 | 38 | private: 39 | 40 | const A objA; 41 | 42 | public: 43 | 44 | ~plus_Ai(){ } 45 | 46 | plus_Ai (const A &a) : objA(a){ } 47 | 48 | T operator () (const int N1) const 49 | { 50 | return objA (N1); 51 | } 52 | 53 | int get_dim1() const 54 | { 55 | return objA.get_dim1(); 56 | } 57 | 58 | friend std::ostream & operator<< (std::ostream & os, const plus_Ai & v) 59 | { 60 | os << std::endl << "BEGIN:plus_Ai =" << &v << std::endl 61 | << ", A = "<< (v.objA) 62 | << "END.plus_Ai " << std::endl; 63 | return os; 64 | } 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Plus_Tensors/Plus_TensorsRank2.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Plus_TensorsRank2_H 27 | #define Plus_TensorsRank2_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define Plus = +A(i,j) 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T> 35 | class plus_Aij 36 | { 37 | 38 | private: 39 | 40 | const A objA; 41 | 42 | public: 43 | 44 | ~plus_Aij(){ } 45 | 46 | plus_Aij (const A &a) : objA(a) { } 47 | 48 | T operator () (const int N1,const int N2) const 49 | { 50 | return objA (N1,N2); 51 | } 52 | 53 | int get_dim1() const 54 | { 55 | return objA.get_dim1(); 56 | } 57 | 58 | int get_dim2() const 59 | { 60 | return objA.get_dim2(); 61 | } 62 | 63 | friend std::ostream & operator<< (std::ostream & os, const plus_Aij & v) 64 | { 65 | os << std::endl << "BEGIN:plus_Aij =" << &v << std::endl 66 | << ", A = "<< (v.objA) 67 | << "END.plus_Aij " << std::endl; 68 | return os; 69 | } 70 | }; 71 | 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Plus_Tensors/Plus_TensorsRank3.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Plus_TensorsRank3_H 27 | #define Plus_TensorsRank3_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define Plus = +A(i,j,k) 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T> 35 | class plus_Aijk 36 | { 37 | 38 | private: 39 | 40 | const A objA; 41 | 42 | public: 43 | 44 | ~plus_Aijk(){ } 45 | 46 | plus_Aijk (const A &a) : objA(a) { } 47 | 48 | T operator () (const int N1,const int N2,const int N3) const 49 | { 50 | return objA (N1,N2,N3); 51 | } 52 | 53 | int get_dim1() const 54 | { 55 | return objA.get_dim1(); 56 | } 57 | 58 | int get_dim2() const 59 | { 60 | return objA.get_dim2(); 61 | } 62 | 63 | int get_dim3() const 64 | { 65 | return objA.get_dim3(); 66 | } 67 | 68 | friend std::ostream & operator<< (std::ostream & os, const plus_Aijk & v) 69 | { 70 | os << std::endl << "BEGIN:plus_Aijk =" << &v << std::endl 71 | << ", A = "<< (v.objA) 72 | << "END.plus_Aijk " << std::endl; 73 | return os; 74 | } 75 | }; 76 | 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Plus_Tensors/Plus_TensorsRank4.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Plus_TensorsRank4_H 27 | #define Plus_TensorsRank4_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define Plus = +A(i,j,k,l) 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T> 35 | class plus_Aijkl 36 | { 37 | 38 | private: 39 | 40 | const A objA; 41 | 42 | public: 43 | 44 | ~plus_Aijkl(){ } 45 | 46 | plus_Aijkl (const A &a) : objA(a) { } 47 | 48 | T operator () (const int N1,const int N2,const int N3,const int N4) const 49 | { 50 | return objA (N1,N2,N3,N4); 51 | } 52 | 53 | int get_dim1() const 54 | { 55 | return objA.get_dim1(); 56 | } 57 | 58 | int get_dim2() const 59 | { 60 | return objA.get_dim2(); 61 | } 62 | 63 | int get_dim3() const 64 | { 65 | return objA.get_dim3(); 66 | } 67 | 68 | int get_dim4() const 69 | { 70 | return objA.get_dim4(); 71 | } 72 | 73 | friend std::ostream & operator<< (std::ostream & os, const plus_Aijkl & v) 74 | { 75 | os << std::endl << "BEGIN:plus_Aijkl =" << &v << std::endl 76 | << ", A = "<< (v.objA) 77 | << "END.plus_Aijkl " << std::endl; 78 | return os; 79 | } 80 | }; 81 | 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Subtract_Tensors/Subtract_Tensors.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Subtract_Tensors_H 27 | #define Subtract_Tensors_H 28 | 29 | #include "./Subtract_TensorsRank1.h" 30 | #include "./Subtract_TensorsRank2.h" 31 | #include "./Subtract_TensorsRank3.h" 32 | #include "./Subtract_TensorsRank4.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Subtract_Tensors/Subtract_TensorsRank1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Subtract_TensorsRank1_H 27 | #define Subtract_TensorsRank1_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define Subtraction = A(i)-B(i) 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class B, class T> 35 | class Ai_minus_Bi 36 | { 37 | 38 | private: 39 | 40 | const A objA; 41 | const B objB; 42 | 43 | public: 44 | 45 | ~Ai_minus_Bi(){ } 46 | 47 | Ai_minus_Bi (const A &a, const B &b) : objA(a), objB(b) 48 | { 49 | #ifdef USE_ASSERT_Tensor_Operations 50 | assert (objA.get_dim1() == objB.get_dim1()); 51 | #endif 52 | } 53 | 54 | T operator () (const int N1) const 55 | { 56 | return objA (N1) - objB (N1); 57 | } 58 | 59 | int get_dim1() const 60 | { 61 | return objA.get_dim1(); 62 | } 63 | 64 | friend std::ostream & operator<< (std::ostream & os, const Ai_minus_Bi & v) 65 | { 66 | os << std::endl << "BEGIN:Ai_minus_Bi =" << &v << std::endl 67 | << ", L = "<< (v.objA) 68 | << ", R = " << (v.objB) 69 | << "END.Ai_minus_Bi " << std::endl; 70 | return os; 71 | } 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Sum_Tensors/Sum_Tensors.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Sum_Tensors_H 27 | #define Sum_Tensors_H 28 | 29 | #include "./Sum_TensorsRank1.h" 30 | #include "./Sum_TensorsRank2.h" 31 | #include "./Sum_TensorsRank3.h" 32 | #include "./Sum_TensorsRank4.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Sum_Tensors/Sum_TensorsRank1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Sum_TensorsRank1_H 27 | #define Sum_TensorsRank1_H 28 | 29 | #include "../../Promote_Types/promote.h" 30 | 31 | /////////////////////////////////////////////// 32 | // Define SUM = A(i)+B(i) 33 | /////////////////////////////////////////////// 34 | 35 | 36 | 37 | template < class A, class B, class T> 38 | class Ai_plus_Bi 39 | { 40 | 41 | private: 42 | 43 | const A objA; 44 | const B objB; 45 | 46 | public: 47 | 48 | ~Ai_plus_Bi(){ } 49 | 50 | Ai_plus_Bi (const A &a, const B &b) : objA(a), objB(b) 51 | { 52 | #ifdef USE_ASSERT_Tensor_Operations 53 | assert (objA.get_dim1() == objB.get_dim1()); 54 | #endif 55 | } 56 | 57 | inline T operator () (const int N1) const 58 | { 59 | return objA (N1) + objB (N1); 60 | } 61 | 62 | int get_dim1() const 63 | { 64 | return objA.get_dim1(); 65 | } 66 | 67 | friend std::ostream & operator<< (std::ostream & os, const Ai_plus_Bi & v) 68 | { 69 | os << std::endl << "BEGIN:Ai_plus_Bi =" << &v << std::endl 70 | << ", L = "<< (v.objA) 71 | << ", R = " << (v.objB) 72 | << "END.Ai_plus_Bi " << std::endl; 73 | return os; 74 | } 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Sum_Tensors/Sum_TensorsRank3.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Sum_TensorsRank3_H 27 | #define Sum_TensorsRank3_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define SUM = A(i,j)+B(i,j) 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class B, class T> 35 | class Aijk_plus_Bijk 36 | { 37 | 38 | private: 39 | 40 | const A objA; 41 | const B objB; 42 | 43 | public: 44 | 45 | ~Aijk_plus_Bijk(){ } 46 | 47 | Aijk_plus_Bijk (const A &a, const B &b) : objA(a), objB(b) 48 | { 49 | #ifdef USE_ASSERT_Tensor_Operations 50 | assert (objA.get_dim1() == objB.get_dim1()); 51 | assert (objA.get_dim2() == objB.get_dim2()); 52 | assert (objA.get_dim3() == objB.get_dim3()); 53 | #endif 54 | } 55 | 56 | T operator () (const int N1,const int N2,const int N3) const 57 | { 58 | return objA (N1,N2,N3) + objB (N1,N2,N3); 59 | } 60 | 61 | int get_dim1() const 62 | { 63 | return objA.get_dim1(); 64 | } 65 | 66 | int get_dim2() const 67 | { 68 | return objA.get_dim2(); 69 | } 70 | 71 | int get_dim3() const 72 | { 73 | return objA.get_dim3(); 74 | } 75 | 76 | friend std::ostream & operator<< (std::ostream & os, const Aijk_plus_Bijk & v) 77 | { 78 | os << std::endl << "BEGIN:Aijk_plus_Bijk =" << &v << std::endl 79 | << ", L = "<< (v.objA) 80 | << ", R = " << (v.objB) 81 | << "END.Aij_plus_Bij " << std::endl; 82 | return os; 83 | } 84 | }; 85 | 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_Contractions/Tensor1_contracts_Tensor1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | ///////////////////////////////////////////////////////// 27 | // Define FUNCTIONS to perform operations of type: 28 | /*!brief A(i)*B(i) */ 29 | ////////////////////////////////////////////////////////// 30 | 31 | #ifndef Tensor1_contracts_Tensor1_H 32 | #define Tensor1_contracts_Tensor1_H 33 | 34 | 35 | template 36 | inline T Ai_contracts_Bi(const A & ExprL, const B & ExprR) 37 | { 38 | #ifdef USE_ASSERT_Tensor_Operations 39 | assert (ExprL.get_dim1() == ExprR.get_dim1()); 40 | #endif 41 | T res = 0; 42 | int n1; 43 | const int dim1 = ExprL.get_dim1(); 44 | for(n1 = 0 ; n1 < dim1; ++n1) 45 | { 46 | res += ExprL(n1)*ExprR(n1); 47 | } 48 | return res; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_Contractions/Tensor3_contracts_Tensor1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | 27 | ///////////////////////////////////////////////////////// 28 | // Define FUNCTIONS to perform operations of type: 29 | /*!brief A(i,j,k)*B(k) */ 30 | ////////////////////////////////////////////////////////// 31 | 32 | #ifndef Tensor3_contracts_Tensor1_H 33 | #define Tensor3_contracts_Tensor1_H 34 | 35 | 36 | template < class A, class B, class T> 37 | class Aijk_contracts_Bk 38 | { 39 | const A ObjA; 40 | const B ObjB; 41 | public: 42 | 43 | Aijk_contracts_Bk (const A &a, const B &b): ObjA(a), ObjB(b) 44 | { 45 | #ifdef USE_ASSERT_Tensor_Operations 46 | assert (a.get_dim3() == b.get_dim1()); 47 | #endif 48 | } 49 | 50 | T operator () (const int N1, const int N2) const 51 | { 52 | T res=0; 53 | int n1; 54 | const int dim1 = ObjA.get_dim3(); 55 | for(n1 = 0; n1< dim1;++n1) 56 | { 57 | res += ObjA(N1,N2,n1)*ObjB(n1); 58 | } 59 | return res; 60 | } 61 | 62 | int get_dim1() const 63 | { 64 | return ObjA.get_dim1(); 65 | } 66 | 67 | int get_dim2() const 68 | { 69 | return ObjA.get_dim2(); 70 | } 71 | 72 | 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_Contractions/Tensor4_contracts_Tensor1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | ///////////////////////////////////////////////////////// 27 | // Define FUNCTIONS to perform operations of type: 28 | // A(i,j,k,l)*B(l), etc 29 | ////////////////////////////////////////////////////////// 30 | 31 | #ifndef Tensor4_contracts_Tensor1_H 32 | #define Tensor4_contracts_Tensor1_H 33 | 34 | 35 | template < class A, class B, class T> 36 | class Aijkl_contracts_Bl 37 | { 38 | const A ObjA; 39 | const B ObjB; 40 | public: 41 | 42 | Aijkl_contracts_Bl (const A &a, const B &b): ObjA(a), ObjB(b) 43 | { 44 | #ifdef USE_ASSERT_Tensor_Operations 45 | assert (a.get_dim4() == b.get_dim1()); 46 | #endif 47 | } 48 | 49 | T operator () (const int N1, const int N2, const int N3) const 50 | { 51 | T res=0; 52 | int n1; 53 | const int dim1 = ObjA.get_dim4(); 54 | for(n1 = 0; n1< dim1;++n1) 55 | { 56 | res += ObjA(N1,N2,N3,n1)*ObjB(n1); 57 | } 58 | return res; 59 | } 60 | 61 | int get_dim1() const 62 | { 63 | return ObjA.get_dim1(); 64 | } 65 | 66 | int get_dim2() const 67 | { 68 | return ObjA.get_dim2(); 69 | } 70 | 71 | int get_dim3() const 72 | { 73 | return ObjA.get_dim3(); 74 | } 75 | 76 | }; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_Contractions/Tensor_Contractions.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Tensor_Contractions_H 27 | #define Tensor_Contractions_H 28 | 29 | #include "./Tensor1_contracts_Tensor1.h" 30 | #include "./Tensor2_contracts_Tensor1.h" 31 | #include "./Tensor2_contracts_Tensor2.h" 32 | #include "./Tensor3_contracts_Tensor1.h" 33 | #include "./Tensor3_contracts_Tensor2.h" 34 | #include "./Tensor3_contracts_Tensor3.h" 35 | #include "./Tensor4_contracts_Tensor1.h" 36 | #include "./Tensor4_contracts_Tensor2.h" 37 | #include "./Tensor4_contracts_Tensor3.h" 38 | #include "./Tensor4_contracts_Tensor4.h" 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_Operations.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #include "./Encapsulate_Tensors/Encapsulate_Tensors.h" 27 | #include "./Permute_Tensors/Permute_Tensors.h" 28 | #include "./Equate_Tensors/Equate_Tensors.h" 29 | #include "./Sum_Tensors/Sum_Tensors.h" 30 | #include "./Subtract_Tensors/Subtract_Tensors.h" 31 | #include "./Plus_Tensors/Plus_Tensors.h" 32 | #include "./Minus_Tensors/Minus_Tensors.h" 33 | #include "./Tensor_times_Scalar/Tensor_times_Scalar.h" 34 | #include "./Tensor_divided_Scalar/Tensor_divided_Scalar.h" 35 | #include "./Tensor_Contractions/Tensor_Contractions.h" 36 | #include "./Tensor_times_Tensor/Tensor_times_Tensor.h" 37 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_divided_Scalar/TensorRank1_divided_Scalar.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef TensorRank1_divided_Scalar_H 27 | #define TensorRank1_divided_Scalar_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define division by scalar = A(i)/u 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T, class U> class Ai_divided_u 35 | { 36 | const A objA; 37 | const U u; 38 | public: 39 | 40 | 41 | Ai_divided_u (const A &a, const U & u0): 42 | objA(a), u(u0) 43 | { 44 | } 45 | 46 | T operator () (const int N) const 47 | { 48 | return objA (N) / u; 49 | } 50 | 51 | int get_dim1 () const 52 | { 53 | return objA.get_dim1(); 54 | } 55 | 56 | }; 57 | 58 | 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_divided_Scalar/TensorRank2_divided_Scalar.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef TensorRank2_divided_Scalar_H 27 | #define TensorRank2_divided_Scalar_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define division by scalar = A(i,j)/u 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T, class U> class Aij_divided_u 35 | { 36 | const A objA; 37 | const U u; 38 | public: 39 | 40 | 41 | Aij_divided_u (const A &a, const U & u0): 42 | objA(a), u(u0) 43 | { 44 | } 45 | 46 | T operator () (const int N1,const int N2) const 47 | { 48 | return objA (N1,N2) / u; 49 | } 50 | 51 | int get_dim1 () const 52 | { 53 | return objA.get_dim1(); 54 | } 55 | 56 | int get_dim2 () const 57 | { 58 | return objA.get_dim2(); 59 | } 60 | }; 61 | 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_divided_Scalar/TensorRank3_divided_Scalar.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef TensorRank3_divided_Scalar_H 27 | #define TensorRank3_divided_Scalar_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define division by scalar = A(i,j,k)*u 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T, class U> class Aijk_divided_u 35 | { 36 | const A objA; 37 | const U u; 38 | public: 39 | 40 | 41 | Aijk_divided_u (const A &a, const U & u0): objA(a), u(u0) {} 42 | 43 | T operator () (const int N1,const int N2,const int N3) const 44 | { 45 | return objA (N1,N2,N3) / u; 46 | } 47 | 48 | int get_dim1 () const 49 | { 50 | return objA.get_dim1(); 51 | } 52 | 53 | int get_dim2 () const 54 | { 55 | return objA.get_dim2(); 56 | } 57 | int get_dim3 () const 58 | { 59 | return objA.get_dim3(); 60 | } 61 | }; 62 | 63 | 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_divided_Scalar/TensorRank4_divided_Scalar.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef TensorRank4_divided_Scalar_H 27 | #define TensorRank4_divided_Scalar_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define division by scalar = A(i,j,k,l)/u 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T, class U> 35 | class Aijkl_divided_u 36 | { 37 | const A objA; 38 | const U u; 39 | public: 40 | 41 | 42 | Aijkl_divided_u (const A &a, const U & u0): objA(a), u(u0) {} 43 | 44 | T operator () (const int N1,const int N2,const int N3,const int N4) const 45 | { 46 | return objA (N1,N2,N3,N4) / u; 47 | } 48 | 49 | int get_dim1 () const 50 | { 51 | return objA.get_dim1(); 52 | } 53 | 54 | int get_dim2 () const 55 | { 56 | return objA.get_dim2(); 57 | } 58 | int get_dim3 () const 59 | { 60 | return objA.get_dim3(); 61 | } 62 | int get_dim4 () const 63 | { 64 | return objA.get_dim4(); 65 | } 66 | 67 | }; 68 | 69 | 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_divided_Scalar/Tensor_divided_Scalar.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Tensor_divided_Scalar_H 27 | #define Tensor_divided_Scalar_H 28 | 29 | #include "./TensorRank1_divided_Scalar.h" 30 | #include "./TensorRank2_divided_Scalar.h" 31 | #include "./TensorRank3_divided_Scalar.h" 32 | #include "./TensorRank4_divided_Scalar.h" 33 | 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_times_Scalar/TensorRank1_times_Scalar.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef TensorRank1_times_Scalar_H 27 | #define TensorRank1_times_Scalar_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define multiplication by scalar = A(i)*u 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T, class U> class Ai_times_u 35 | { 36 | const A objA; 37 | const U u; 38 | public: 39 | 40 | 41 | Ai_times_u (const A &a, const U & u0): 42 | objA(a), u(u0) 43 | { 44 | } 45 | 46 | T operator () (const int N) const 47 | { 48 | return objA (N) * u; 49 | } 50 | 51 | int get_dim1 () const 52 | { 53 | return objA.get_dim1(); 54 | } 55 | 56 | }; 57 | 58 | 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_times_Scalar/TensorRank2_times_Scalar.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef TensorRank2_times_Scalar_H 27 | #define TensorRank2_times_Scalar_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define multiplication by scalar = A(i,j)*u 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T, class U> class Aij_times_u 35 | { 36 | const A objA; 37 | const U u; 38 | public: 39 | 40 | 41 | Aij_times_u (const A &a, const U & u0): 42 | objA(a), u(u0) 43 | { 44 | } 45 | 46 | T operator () (const int N1,const int N2) const 47 | { 48 | return objA (N1,N2) * u; 49 | } 50 | 51 | int get_dim1 () const 52 | { 53 | return objA.get_dim1(); 54 | } 55 | 56 | int get_dim2 () const 57 | { 58 | return objA.get_dim2(); 59 | } 60 | }; 61 | 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_times_Scalar/TensorRank3_times_Scalar.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef TensorRank3_times_Scalar_H 27 | #define TensorRank3_times_Scalar_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define multiplication by scalar = A(i,j,k)*u 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T, class U> class Aijk_times_u 35 | { 36 | const A objA; 37 | const U u; 38 | public: 39 | 40 | 41 | Aijk_times_u (const A &a, const U & u0): objA(a), u(u0) {} 42 | 43 | T operator () (const int N1,const int N2,const int N3) const 44 | { 45 | return objA (N1,N2,N3) * u; 46 | } 47 | 48 | int get_dim1 () const 49 | { 50 | return objA.get_dim1(); 51 | } 52 | 53 | int get_dim2 () const 54 | { 55 | return objA.get_dim2(); 56 | } 57 | int get_dim3 () const 58 | { 59 | return objA.get_dim3(); 60 | } 61 | }; 62 | 63 | 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_times_Scalar/TensorRank4_times_Scalar.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef TensorRank4_times_Scalar_H 27 | #define TensorRank4_times_Scalar_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define multiplication by scalar = A(i,j,k,l)*u 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T, class U> class Aijkl_times_u 35 | { 36 | const A objA; 37 | const U u; 38 | public: 39 | 40 | 41 | Aijkl_times_u (const A &a, const U & u0): objA(a), u(u0) {} 42 | 43 | T operator () (const int N1,const int N2,const int N3,const int N4) const 44 | { 45 | return objA (N1,N2,N3,N4) * u; 46 | } 47 | 48 | int get_dim1() const 49 | { 50 | return objA.get_dim1(); 51 | } 52 | 53 | int get_dim2() const 54 | { 55 | return objA.get_dim2(); 56 | } 57 | int get_dim3() const 58 | { 59 | return objA.get_dim3(); 60 | } 61 | int get_dim4() const 62 | { 63 | return objA.get_dim4(); 64 | } 65 | }; 66 | 67 | 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_times_Scalar/Tensor_times_Scalar.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Tensor_times_Scalar_H 27 | #define Tensor_times_Scalar_H 28 | 29 | #include "./TensorRank1_times_Scalar.h" 30 | #include "./TensorRank2_times_Scalar.h" 31 | #include "./TensorRank3_times_Scalar.h" 32 | #include "./TensorRank4_times_Scalar.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_times_Tensor/Tensor1_times_Tensor1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Tensor1_times_Tensor1_H 27 | #define Tensor1_times_Tensor1_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | /*!brief A(i)*B(j) */ 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T, class B> class Ai_times_Bj 35 | { 36 | const A objA; 37 | const B objB; 38 | public: 39 | 40 | 41 | Ai_times_Bj (const A &a, const B & b): 42 | objA(a), objB(b) 43 | { 44 | } 45 | 46 | T operator () (const int N1,const int N2) const 47 | { 48 | return objA (N1) * objB (N2); 49 | } 50 | 51 | int get_dim1() const 52 | { 53 | return objA.get_dim1(); 54 | } 55 | 56 | int get_dim2() const 57 | { 58 | return objB.get_dim1(); 59 | } 60 | }; 61 | 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_times_Tensor/Tensor2_times_Tensor1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Tensor2_times_Tensor1_H 27 | #define Tensor2_times_Tensor1_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | /*!brief A(i,j)*B(k) */ 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T, class B> class Aij_times_Bk 35 | { 36 | const A objA; 37 | const B objB; 38 | public: 39 | 40 | 41 | Aij_times_Bk (const A &a, const B & b): objA(a), objB(b){ } 42 | 43 | T operator () (const int N1,const int N2,const int N3) const 44 | { 45 | return objA (N1,N2) * objB (N3); 46 | } 47 | 48 | int get_dim1() const 49 | { 50 | return objA.get_dim1(); 51 | } 52 | 53 | int get_dim2() const 54 | { 55 | return objA.get_dim2(); 56 | } 57 | 58 | int get_dim3() const 59 | { 60 | return objB.get_dim1(); 61 | } 62 | 63 | }; 64 | 65 | 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_times_Tensor/Tensor2_times_Tensor2.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Tensor2_times_Tensor2_H 27 | #define Tensor2_times_Tensor2_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | /*!brief A(i,j)*B(k,l) */ 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T, class B> class Aij_times_Bkl 35 | { 36 | const A objA; 37 | const B objB; 38 | public: 39 | 40 | 41 | Aij_times_Bkl (const A &a, const B & b): objA(a), objB(b){ } 42 | 43 | T operator () (const int N1,const int N2,const int N3,const int N4) const 44 | { 45 | return objA (N1,N2) * objB (N3,N4); 46 | } 47 | 48 | int get_dim1() const 49 | { 50 | return objA.get_dim1(); 51 | } 52 | 53 | int get_dim2() const 54 | { 55 | return objA.get_dim2(); 56 | } 57 | 58 | int get_dim3() const 59 | { 60 | return objB.get_dim1(); 61 | } 62 | 63 | int get_dim4() const 64 | { 65 | return objB.get_dim2(); 66 | } 67 | }; 68 | 69 | 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_times_Tensor/Tensor3_times_Tensor1.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Tensor3_times_Tensor1_H 27 | #define Tensor3_times_Tensor1_H 28 | 29 | 30 | /////////////////////////////////////////////// 31 | // Define tensor outer product = A(i,j,k)*B(l) 32 | /////////////////////////////////////////////// 33 | 34 | template < class A, class T, class B> class Aijk_times_Bl 35 | { 36 | const A objA; 37 | const B objB; 38 | public: 39 | 40 | 41 | Aijk_times_Bl (const A &a, const B & b): objA(a), objB(b){ } 42 | 43 | T operator () (const int N1,const int N2,const int N3,const int N4) const 44 | { 45 | return objA (N1,N2,N3) * objB (N4); 46 | } 47 | 48 | int get_dim1() const 49 | { 50 | return objA.get_dim1(); 51 | } 52 | 53 | int get_dim2() const 54 | { 55 | return objA.get_dim2(); 56 | } 57 | 58 | int get_dim3() const 59 | { 60 | return objA.get_dim3(); 61 | } 62 | 63 | int get_dim4() const 64 | { 65 | return objB.get_dim1(); 66 | } 67 | }; 68 | 69 | 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/Tensor_times_Tensor/Tensor_times_Tensor.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef Tensor_times_Tensor_H 27 | #define Tensor_times_Tensor_H 28 | 29 | #include "./Tensor1_times_Tensor1.h" 30 | #include "./Tensor2_times_Tensor1.h" 31 | #include "./Tensor3_times_Tensor1.h" 32 | #include "./Tensor2_times_Tensor2.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /ltensor/Tensor_Operations/check_Tensor_Operations.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef check_Tensor_Operations_H 27 | //#define check_Tensor_Operations_H 28 | // 29 | //#define USE_ASSERT_Tensor_Operations 30 | //#ifdef USE_ASSERT_Tensor_Operations 31 | //#include 32 | //#endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /ltensor/algorithms/algorithms.h: -------------------------------------------------------------------------------- 1 | #ifndef ALGORITHM_H 2 | #define ALGORITHM_H 3 | 4 | template 5 | T Sign(T t) 6 | { 7 | if( t == 0 ) 8 | return T(0); 9 | else 10 | return ( t < 0 ? T(-1) : T(1) ); 11 | } 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /ltensor/apple.cpp: -------------------------------------------------------------------------------- 1 | #include "apple.h" 2 | 3 | 4 | apple::apple(int ww): 5 | vec(6,0.) 6 | { 7 | weight = ww; 8 | } 9 | apple::apple(): 10 | vec(6,0.) 11 | { 12 | weight = 0. ; 13 | } 14 | 15 | apple::~apple() 16 | { 17 | 18 | } 19 | 20 | int apple::setWeight(double wei){ 21 | weight = wei ; 22 | double cc{1.}; 23 | vec[0] = cc; 24 | 25 | 26 | vector ret(6,0.); 27 | vector > matrix(6,vector(6,0.)); 28 | 29 | matrix[0][0] =123; 30 | matrix[2][4] =23; 31 | 32 | for (int i = 0; i < 6; ++i) 33 | { 34 | for (int j = 0; j < 6; ++j) 35 | { 36 | ret[i] += matrix[i][j]* vec[j]; 37 | } 38 | } 39 | 40 | cout<<"ret[0] "< 2 | #include 3 | using namespace std; 4 | class apple 5 | { 6 | public: 7 | apple(int num); 8 | apple(); 9 | ~apple(); 10 | 11 | int setWeight(double ); 12 | double getWeight(); 13 | 14 | private: 15 | vector vec; 16 | double weight; 17 | }; -------------------------------------------------------------------------------- /ltensor/base/Constants.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | /*! \brief Enum describing common ordering styles*/ 27 | enum STORAGE{CSTYLE,FORTRANSTYLE}; 28 | -------------------------------------------------------------------------------- /ltensor/base/Range.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // LTensor // 4 | // // 5 | // A Tensor Library with full Indicial Notation // 6 | // // 7 | // Version 0.1 // 8 | // December 1, 2008 // 9 | // // 10 | // Copyright (C) 2007-2009-... // 11 | // Alejandro Limache & Sebastian Rojas Fredini // 12 | // // 13 | // International Center of Computational Methods in Engineering (CIMEC) // 14 | // Santa Fe, Argentina // 15 | // alejandrolimache@gmail.com // 16 | // // 17 | // LTensor is freely available through the websites: // 18 | // http://www.cimec.org.ar/alimache/ // 19 | // http://code.google.com/p/ltensor/ // 20 | // It may be copied, modified, and redistributed for non-commercial use as // 21 | // long as the original authors and the Library get proper public credit // 22 | // for its use. // 23 | // Please consult the file LICENSE for the detailed copyright notices. // 24 | // // 25 | /////////////////////////////////////////////////////////////////////////////// 26 | #ifndef RANGE_H_INCLUDED 27 | #define RANGE_H_INCLUDED 28 | #include "../static/sVector.h" 29 | #include 30 | 31 | //template only valid for integer types 32 | 33 | 34 | template 35 | class Range{ 36 | public: 37 | 38 | enum Predet{ALL,LHALF,RHALF,EVENS,ODDS,FIXED}; 39 | Type init; 40 | Type stride; 41 | Type end; 42 | int pred; 43 | int size; 44 | bool rev; 45 | 46 | Range(Type init,Type stride,Type end){ 47 | this->init=init; 48 | this->stride=stride; 49 | this->end=end; 50 | size=end-init>=0? (end-init+1)/abs(stride): (init-end+1)/abs(stride); 51 | if(this->end<=this->init) 52 | rev=true; 53 | else 54 | rev=false; 55 | } 56 | Range(){ 57 | size=0; 58 | 59 | } 60 | 61 | Range(int pred){ 62 | this->pred=pred; 63 | } 64 | 65 | Range (int pred,int fixed){ 66 | this->pred=pred; 67 | this->size=fixed; 68 | 69 | } 70 | 71 | Type* getVector(){ 72 | 73 | Type* vec=new Type[size]; 74 | if (rev){ 75 | for (Type i=init;i>=end;i+=stride) 76 | vec[init-i]=i; 77 | return vec; 78 | 79 | 80 | }else{ 81 | for (Type i=init;i<=end;i+=stride) 82 | vec[i]=i; 83 | return vec; 84 | } 85 | 86 | 87 | } 88 | 89 | 90 | }; 91 | 92 | 93 | #endif // RANGE_H_INCLUDED 94 | -------------------------------------------------------------------------------- /ltensor/main.cpp: -------------------------------------------------------------------------------- 1 | #include "LTensor.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | vector v1(6,0.) ; 11 | 12 | void test(){ 13 | double cc{1.} ; 14 | v1[0] = cc; 15 | cout<< "v1[0] " << v1[0] < i; 22 | Index<'j'> j; 23 | Marray q(2); 24 | Marray p(2); 25 | Marray A(2,2); 26 | q(i)=A(i,j)*p(j); 27 | cout< > tensor_vector(10) ; 36 | tensor_vector.push_back(A); 37 | // tensor_vector[1] = A; 38 | cout<< "tensor_vector.size " << tensor_vector.size()< > v(3,std::vector(3,0.) ) ; 47 | cout< v1; 50 | v1 = v[0] ; 51 | 52 | cout< radius{ 66 | 2.7, 2.74, 2.8, 2.82, 2.85, 67 | 2.9, 3.0, 3.1, 3.25, 3.5, 68 | 4.2, 5.3, 6.5, 7.5, 10.0, 12.65 69 | }; 70 | 71 | cout< 3 | 4 | using namespace std; 5 | int main(int argc, char const *argv[]) 6 | { 7 | apple ap1(3.0) ; 8 | 9 | ap1.setWeight(4.0); 10 | 11 | cout<<"Done!"< 31 | 32 | class HRTimer { 33 | 34 | public: 35 | 36 | struct timeval beg; 37 | struct timeval end; 38 | struct timezone tz; 39 | 40 | void Start(void) { 41 | gettimeofday(&beg, &tz); 42 | }; 43 | void Stop(void) { 44 | gettimeofday(&end, &tz); 45 | }; 46 | double GetDurationInSecs(void) 47 | { 48 | 49 | double duration = (end.tv_sec+end.tv_usec*1e-6)- (beg.tv_sec+beg.tv_usec*1e-6); 50 | return duration; 51 | } 52 | }; 53 | #else 54 | 55 | #include 56 | // very simple, high-precision (at least in theory) timer for timing API calls 57 | struct HRTimer { 58 | 59 | LARGE_INTEGER freq; 60 | void Init(){ 61 | QueryPerformanceFrequency(&freq); 62 | } 63 | void Start(void) { 64 | QueryPerformanceCounter(&mTimeStart); 65 | }; 66 | void Stop(void) { 67 | QueryPerformanceCounter(&mTimeStop); 68 | }; 69 | double GetDurationInSecs(void) 70 | { 71 | 72 | double duration = (double)(mTimeStop.QuadPart-mTimeStart.QuadPart)/(double)freq.QuadPart; 73 | return duration; 74 | } 75 | 76 | LARGE_INTEGER mTimeStart; 77 | LARGE_INTEGER mTimeStop; 78 | }; 79 | 80 | 81 | 82 | #endif 83 | 84 | --------------------------------------------------------------------------------