1 #ifndef INTREPID_REALSPACETOOLSDEF_KOKKOS_HPP
2 #define INTREPID_REALSPACETOOLSDEF_KOKKOS_HPP
4 #ifdef INTREPID_OLD_KOKKOS_CODE
5 #ifdef Kokkos_ENABLE_CXX11
10 template<
class Scalar1,
class Scalar2,
class Layout,
class MemorySpace>
11 void RealSpaceTools<Scalar>::inverseTemp(Kokkos::View<Scalar1,Layout,MemorySpace> & inverseMats,
const Kokkos::View<Scalar2,Layout,MemorySpace> & inMats){
13 ArrayWrapper<Scalar1,Kokkos::View<Scalar1,Layout,MemorySpace>, Rank<Kokkos::View<Scalar1,Layout,MemorySpace> >::value,
false>inverseMatsWrap(inverseMats);
14 ArrayWrapper<Scalar2,Kokkos::View<Scalar2,Layout,MemorySpace>, Rank<Kokkos::View<Scalar2,Layout,MemorySpace> >::value,
true>inMatsWrap(inMats);
16 int arrayRank = getrank(inMats);
20 int dim = inMats.dimension(arrayRank-2);
25 dim_i0 = inMats.dimension(0);
26 dim_i1 = inMats.dimension(1);
30 Kokkos::parallel_for (dim_i0, [&] (
const int i0) {
32 for (
int i1=0; i1<dim_i1; i1++) {
35 int i, j, rowID = 0, colID = 0;
36 int rowperm[3]={0,1,2};
37 int colperm[3]={0,1,2};
42 if( std::abs( inMatsWrap(i0,i1,i,j) ) > emax){
43 rowID = i; colID = j; emax = std::abs( inMatsWrap(i0,i1,i,j) );
56 Scalar B[3][3], S[2][2], Bi[3][3];
59 B[i][j] = inMatsWrap(i0,i1,rowperm[i],colperm[j]);
62 B[1][0] /= B[0][0]; B[2][0] /= B[0][0];
65 S[i][j] = B[i+1][j+1] - B[i+1][0] * B[0][j+1];
68 Scalar detS = S[0][0]*S[1][1]- S[0][1]*S[1][0], Si[2][2];
71 Si[0][0] = S[1][1]/detS; Si[0][1] = -S[0][1]/detS;
72 Si[1][0] = -S[1][0]/detS; Si[1][1] = S[0][0]/detS;
75 Bi[0][j+1] = -( B[0][1]*Si[0][j] + B[0][2]* Si[1][j])/B[0][0];
77 Bi[i+1][0] = -(Si[i][0]*B[1][0] + Si[i][1]*B[2][0]);
79 Bi[0][0] = ((Scalar)1/B[0][0])-Bi[0][1]*B[1][0]-Bi[0][2]*B[2][0];
86 inverseMatsWrap(i0,i1,i,j) = Bi[colperm[i]][rowperm[j]];
96 Kokkos::parallel_for (dim_i0, [&] (
const int i0) {
99 for (
int i1=0; i1<dim_i1; i1++) {
102 Scalar determinant = inMatsWrap(i0,i1,0,0)*inMatsWrap(i0,i1,1,1)-inMatsWrap(i0,i1,0,1)*inMatsWrap(i0,i1,1,0);
104 inverseMatsWrap(i0,i1,0,0) = inMatsWrap(i0,i1,1,1) / determinant;
105 inverseMatsWrap(i0,i1,0,1) = - inMatsWrap(i0,i1,0,1) / determinant;
107 inverseMatsWrap(i0,i1,1,0) = - inMatsWrap(i0,i1,1,0) / determinant;
108 inverseMatsWrap(i0,i1,1,1) = inMatsWrap(i0,i1,0,0) / determinant;
115 Kokkos::parallel_for (dim_i0, [&] (
const int i0) {
117 for (
int i1=0; i1<dim_i1; i1++) {
118 inverseMatsWrap(i0,i1,0,0) = (Scalar)1 / inMatsWrap(i0,i1,0,0);
129 dim_i1 = inMats.dimension(0);
132 Kokkos::parallel_for (dim_i1, [&] (
const int i1) {
134 int i, j, rowID = 0, colID = 0;
135 int rowperm[3]={0,1,2};
136 int colperm[3]={0,1,2};
139 for(i=0; i < 3; ++i){
140 for(j=0; j < 3; ++j){
141 if( std::abs( inMatsWrap(i1,i,j) ) > emax){
142 rowID = i; colID = j; emax = std::abs( inMatsWrap(i1,i,j) );
155 Scalar B[3][3], S[2][2], Bi[3][3];
156 for(i=0; i < 3; ++i){
157 for(j=0; j < 3; ++j){
158 B[i][j] = inMatsWrap(i1,rowperm[i],colperm[j]);
161 B[1][0] /= B[0][0]; B[2][0] /= B[0][0];
162 for(i=0; i < 2; ++i){
163 for(j=0; j < 2; ++j){
164 S[i][j] = B[i+1][j+1] - B[i+1][0] * B[0][j+1];
167 Scalar detS = S[0][0]*S[1][1]- S[0][1]*S[1][0], Si[2][2];
170 Si[0][0] = S[1][1]/detS; Si[0][1] = -S[0][1]/detS;
171 Si[1][0] = -S[1][0]/detS; Si[1][1] = S[0][0]/detS;
174 Bi[0][j+1] = -( B[0][1]*Si[0][j] + B[0][2]* Si[1][j])/B[0][0];
176 Bi[i+1][0] = -(Si[i][0]*B[1][0] + Si[i][1]*B[2][0]);
178 Bi[0][0] = ((Scalar)1/B[0][0])-Bi[0][1]*B[1][0]-Bi[0][2]*B[2][0];
183 for(i=0; i < 3; ++i){
184 for(j=0; j < 3; ++j){
185 inverseMatsWrap(i1,i,j) = Bi[colperm[i]][rowperm[j]];
195 Kokkos::parallel_for (dim_i1, [&] (
const int i1) {
197 Scalar determinant = inMatsWrap(i1,0,0)*inMatsWrap(i1,1,1)-inMatsWrap(i1,0,1)*inMatsWrap(i1,1,0);
199 inverseMatsWrap(i1,0,0) = inMatsWrap(i1,1,1) / determinant;
200 inverseMatsWrap(i1,0,1) = - inMatsWrap(i1,0,1) / determinant;
202 inverseMatsWrap(i1,1,0) = - inMatsWrap(i1,1,0) / determinant;
203 inverseMatsWrap(i1,1,1) = inMatsWrap(i1,0,0) / determinant;
211 Kokkos::parallel_for (dim_i1, [&] (
const int i1) {
212 inverseMatsWrap(i1,0,0) = (Scalar)1 / inMatsWrap(i1,0,0);
225 int i, j, rowID = 0, colID = 0;
226 int rowperm[3]={0,1,2};
227 int colperm[3]={0,1,2};
230 for(i=0; i < 3; ++i){
231 for(j=0; j < 3; ++j){
232 if( std::abs( inMatsWrap(i,j) ) > emax){
233 rowID = i; colID = j; emax = std::abs( inMatsWrap(i,j) );
246 Scalar B[3][3], S[2][2], Bi[3][3];
247 for(i=0; i < 3; ++i){
248 for(j=0; j < 3; ++j){
249 B[i][j] = inMatsWrap(rowperm[i],colperm[j]);
252 B[1][0] /= B[0][0]; B[2][0] /= B[0][0];
253 for(i=0; i < 2; ++i){
254 for(j=0; j < 2; ++j){
255 S[i][j] = B[i+1][j+1] - B[i+1][0] * B[0][j+1];
258 Scalar detS = S[0][0]*S[1][1]- S[0][1]*S[1][0], Si[2][2];
260 Si[0][0] = S[1][1]/detS; Si[0][1] = -S[0][1]/detS;
261 Si[1][0] = -S[1][0]/detS; Si[1][1] = S[0][0]/detS;
264 Bi[0][j+1] = -( B[0][1]*Si[0][j] + B[0][2]* Si[1][j])/B[0][0];
266 Bi[i+1][0] = -(Si[i][0]*B[1][0] + Si[i][1]*B[2][0]);
268 Bi[0][0] = ((Scalar)1/B[0][0])-Bi[0][1]*B[1][0]-Bi[0][2]*B[2][0];
273 for(i=0; i < 3; ++i){
274 for(j=0; j < 3; ++j){
275 inverseMatsWrap(i,j) = Bi[colperm[i]][rowperm[j]];
283 Scalar determinant = inMatsWrap(0,0)*inMatsWrap(1,1)-inMatsWrap(0,1)*inMatsWrap(1,0);
285 inverseMatsWrap(0,0) = inMatsWrap(1,1) / determinant;
286 inverseMatsWrap(0,1) = - inMatsWrap(0,1) / determinant;
288 inverseMatsWrap(1,0) = - inMatsWrap(1,0) / determinant;
289 inverseMatsWrap(1,1) = inMatsWrap(0,0) / determinant;
295 inverseMatsWrap(0,0) = (Scalar)1 / inMatsWrap(0,0);