對稀疏矩陣壓縮後轉置

2021-07-06 06:40:59 字數 1177 閱讀 7065

#include#include//define 

struct arr

;struct st

;//矩陣壓縮

st* change(int arr[3],int x,int y)

//of if

}//of for j

}//of for i

return m;

}//of change

//列印矩陣

void print(st* m)

//of for i

}//of print

//轉置矩陣 演算法1

st* transpose(st* m)

//of if

}//of for j

}//of for i

return t;

}//of trnaspose

//轉置矩陣 演算法2

st* quicktranspose(st* m)

;//記錄對應行列的個數

int position[3]=;//記錄對應元素應該插入的位置

int i,num=0;

t=(st*)malloc(sizeof(st));

t->data=(arr*)malloc(sizeof(arr)*m->num);

t->i=m->j;

t->j=m->i;

t->num=m->num;

for(i=0;inum;i++)

//of for i

for(i=1;i<3;i++)

//of for i

for(i=0;inum;i++)

//of for i

return t;

}//main

int main()

,,,};

printf("壓縮後矩陣為:\n");

m=change(array,4,3);

print(m);

printf("轉置後矩陣為:\n");

t=transpose(m);

print(t);

printf("快速演算法轉置後矩陣為:\n");

t=quicktranspose(m);

print(t);

return 0;

}//of main

稀疏矩陣轉置矩陣

num 矩陣a中某列的非零元素的個數 cpot 初值表示矩陣a中某列第乙個非零元素在b中的位置,並有如下遞推 cpot 1 0 cpot col cpot col 1 num col 1 2 col nu end right.const int maxterm 100 struct sparsema...

稀疏矩陣的壓縮儲存及轉置

稀疏矩陣的壓縮儲存及轉置 include using namespace std 三元組順序表的型別定義 define itemsize 100 typedef struct int row,col int item thnode typedef struct thnode data data 0 ...

稀疏矩陣的壓縮儲存與轉置

稀疏矩陣 m n的矩陣,矩陣中有效值的個數 遠小於無效值的個數,且這些資料的分布沒有規律。1 0 3 0 5 0 0 0 0 0 0 0 0 0 0 2 0 4 0 6 0 0 0 0 0 0 0 0 0 0 稀疏矩陣的壓縮儲存 壓縮儲存值儲存極少數的有效資料。使用 三元組儲存每乙個有效資料,三元組...