X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/Cipher_code.git/blobdiff_plain/6a49f25ff1d42c2a3309c5add09d7b770c903bb1..b7fb3820a92dbb613e535763a5f83d3a74440513:/IDA/test_mat2.cpp?ds=sidebyside diff --git a/IDA/test_mat2.cpp b/IDA/test_mat2.cpp index 20ccca7..474c572 100644 --- a/IDA/test_mat2.cpp +++ b/IDA/test_mat2.cpp @@ -9,8 +9,6 @@ #include #include #include - - #include // std::cout, std::fixed #include #include @@ -79,7 +77,7 @@ void rc4keyperm(byte *key,int len, int rp,byte *sc, int size_DK) { Mat readFullFile(int n, int k, int& sizeFile, int &lc) { // ifstream stream("lena.png", ios::in | ios::binary | ios::ate); - ifstream stream("/home/couturie/ajeter/lena_small.png", ios::in | ios::binary | ios::ate); + ifstream stream("lena_small2.png", ios::in | ios::binary | ios::ate); sizeFile=stream.tellg(); cout< readFullFile(int n, int k, int& sizeFile, int &lc) { Mat readPartialFile(int n, int k, int& sizeFile, int &lc) { // ifstream stream("lena.png", ios::in | ios::binary | ios::ate); - ifstream stream("/home/couturie/ajeter/lena_small.png", ios::in | ios::binary | ios::ate); + ifstream stream("lena_small2.png", ios::in | ios::binary | ios::ate); sizeFile=stream.tellg(); cout<& IDAmat, Cube &invIDAmat, int q, int n, Cube rm1(RM1,1,1,q*n*n/4); rm1.reshape(n/2,n/2,q); - cout<<"rm1"<& IDAmat, Cube &invIDAmat, int q, int n, sub2.submat(n/2,0,n-1,n/2-1)=-rm2+eye>(n/2,n/2); sub2.submat(n/2,n/2,n-1,n-1)=rm2; - cout<<"det"<::from(sub2); cout<& IDAmat, int q, int n, int k, byte* DK) { @@ -222,7 +220,7 @@ void buildPartialRankIDA(Cube& IDAmat, int q, int n, int k, byte* DK) { } */ - cout< IDAmat; Cube invIDAmat; - + + if(full) { IDAmat.resize(n,n,q); @@ -327,28 +326,46 @@ int main( int argc, char *argv[] ) { Mat C; Mat D2; - C=IDAmat.slice(0)*M; + //full +// C=IDAmat.slice(0)*M; + +//partial + C=IDAmat.slice(0).submat(0,0,n-1,k-1)*M; + M.save("M.bin",raw_binary); if(full) { - //Mat D=invIDAmat.slice(0)*C; + Mat D=invIDAmat.slice(0)*C; - mat A=conv_to::from(IDAmat.slice(0).submat(0,0,n-1,n-1)); + /*mat A=conv_to::from(IDAmat.slice(0).submat(0,0,n-1,n-1)); mat B=conv_to::from(C.submat(0,0,n-1,lc-1)); mat D=solve(A,B); - cout<>::from(D); + cout<::from(IDAmat.slice(0).submat(0,0,n-1,k-1)); - mat B=conv_to::from(C.submat(0,0,n-1,lc-1)); + + IDAmat.resize(k,k,q); + invIDAmat.resize(k,k,q); + buildFullRankIDA(IDAmat, invIDAmat, q, k, &DK[0]); + + + mat A=conv_to::from(IDAmat.slice(0).submat(0,0,k-1,k-1)); + + mat B=conv_to::from(C.submat(0,0,k-1,lc-1)); mat D=solve(A,B); +// mat D=inv(A)*B; - cout<>::from(D); +// cout< D=invIDAmat.slice(0)*C.submat(0,0,k-1,lc-1); + + D2=conv_to>::from(D); + cout<