Tensor_Transpose

PURPOSE ^

C/C++ source

SYNOPSIS ^

C/C++ source

DESCRIPTION ^

C/C++ source

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 #include "Fokker_Planck_DKE_loop.h"
0002 #include <stdio.h>
0003 
0004 void Tensor_Transpose(struct Tensor *A){
0005 /*Simple routine to transpose vectors and tensors*/
0006 
0007 /*check *A is a vector*/
0008 if((*A).sizedim[0]!=1 && (*A).sizedim[1]!=1){
0009 int i,j,dim;
0010 int s[2];
0011 
0012 DOUBLE val;
0013 /*printf("A is a matrix\n");*/
0014 /* for(i=0;i<(*A).sizedim[0];i++){
0015     for(j=0;j<i;j++){
0016        val=(*A).vals[i+j*(*A).sizedim[0]];
0017       (*A).vals[i+j*(*A).sizedim[0]]=(*A).vals[j+i*(*A).sizedim[1]];
0018       (*A).vals[j+i*(*A).sizedim[1]]=val;
0019     }
0020  }
0021  
0022   dim=(*A).sizedim[0];
0023  (*A).sizedim[0]=(*A).sizedim[1];
0024  (*A).sizedim[1]=dim;*/
0025 
0026 struct Tensor B;
0027 /*printf("Asize=%i,%i\n",(*A).sizedim[0],(*A).sizedim[1]);*/
0028 s[0]=(*A).sizedim[1];
0029 s[1]=(*A).sizedim[0];
0030 /* printf("s=%i,%i\n",s[0],s[1]);*/
0031 Tensor_Create(2,s,&B);
0032 /*printf("s=%i,%i\n",B.sizedim[0],B.sizedim[1]);*/
0033 
0034 /*printf("Create B\n");*/
0035 for(i=0;ifor(j=0;j/*printf("Copy B\n");*/
0043 for(i=0;i<(*A).size;i++){
0044    (*A).vals[i]=B.vals[i];
0045 } 
0046 free(B.vals);free(B.sizedim);
0047 }
0048    
0049 else{
0050 int a=(*A).sizedim[0];
0051 (*A).sizedim[0]=(*A).sizedim[1];
0052 (*A).sizedim[1]=a;
0053 }
0054 /*printf("done transposing\n");*/
0055 }

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.