modify COMPARE_N in tool, modify attribute of vehicle by using tensor

This commit is contained in:
2024-06-13 23:35:25 +02:00
parent 13f91583bb
commit 9927d6642c
12 changed files with 217 additions and 56 deletions
+10 -5
View File
@@ -130,11 +130,16 @@ tensor_##type* CLONE_TENSOR_##type(tensor_##type *tens){\
return NULL;\
}\
\
void copy_tensor_##type(tensor_##type * dst, tensor_##type * src){\
if(dst!=NULL && src!=NULL && dst->dim->rank == src->dim->rank){ \
for(size_t i=0; i<(dst->dim)->rank;++i)\
dst->x[i]=src->x[i];\
}\
int copy_tensor_##type(tensor_##type * dst, tensor_##type * src){\
if(dst!=NULL && src!=NULL){ \
int diff = dst->dim->rank - src->dim->rank;\
if(diff == 0) \
for(size_t i=0; i<(src->dim)->rank;++i)\
dst->x[i]=src->x[i];\
return diff;\
\
}\
return -1;\
}\
\
void free_tensor_##type(tensor_##type * tens){\
+52
View File
@@ -1705,6 +1705,58 @@ TEST(copy_tensor){
}
TEST(tensorContractnProd_TYPE_DOUBLE_2_2 ){
dimension *d0=create_dim(3);
dimension *d1=create_dim(3);
#if VALGRIND_
d0->perm[0]=1;
d0->perm[1]=2; //3;
d0->perm[2]=3; //3;
d1->perm[0]=2;
d1->perm[1]=3; //3;
d1->perm[2]=1; //3;
#else
d0->perm[0]=1;
d0->perm[1]=22; //3;
d0->perm[2]=52; //3;
d1->perm[0]=52;
d1->perm[1]=22; //3;
d1->perm[2]=1; //3;
#endif
updateRankDim(d0);
updateRankDim(d1);
tensor_TYPE_DOUBLE *M0 = CREATE_TENSOR_TYPE_DOUBLE(d0);
tensor_TYPE_DOUBLE *M1 = CREATE_TENSOR_TYPE_DOUBLE(d1);
for(size_t i=0; i<M0->dim->rank;++i) M0->x[i]=2 ;
for(size_t i=0; i<M1->dim->rank;++i) M1->x[i]=3;
print_tensor_double(M0,"M0");
print_tensor_double(M1,"M1");
tensor_TYPE_DOUBLE *M=NULL;
tensorContractnProd_TYPE_DOUBLE(&M, M0,M1,2);
print_tensor_double(M,"M");
// for(size_t i=0;i<M->dim->rank;++i)
// EXPECT_EQ_TYPE_DOUBLE(M->x[i],MnO->x[i]);
free_tensor_TYPE_DOUBLE(M);
free_tensor_TYPE_DOUBLE(M0);
free_tensor_TYPE_DOUBLE(M1);
}