#include <iostream>
#include <fstream>
#include <vector>
-
-
#include <iostream> // std::cout, std::fixed
#include <iomanip>
#include <math.h>
Mat<byte> 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<<sizeFile<<endl;
stream.seekg(0, ios::beg);
Mat<byte> 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<<sizeFile<<endl;
stream.seekg(0, ios::beg);
Cube<byte> rm1(RM1,1,1,q*n*n/4);
rm1.reshape(n/2,n/2,q);
- cout<<"rm1"<<endl;
+ /* cout<<"rm1"<<endl;
cout<<rm1<<endl;
-
+ */
sub2.submat(n/2,0,n-1,n/2-1)=-rm2+eye<Mat<short>>(n/2,n/2);
sub2.submat(n/2,n/2,n-1,n-1)=rm2;
- cout<<"det"<<endl;
+ /*cout<<"det"<<endl;
mat toto=conv_to<mat>::from(sub2);
cout<<det(toto)<<endl;
-
+ */
invIDAmat.slice(i)=sub2;
}
- cout<<IDAmat<<endl;
- cout<<invIDAmat<<endl;
+ //cout<<IDAmat<<endl;
+ //cout<<invIDAmat<<endl;
}
void buildPartialRankIDA(Cube<byte>& IDAmat, int q, int n, int k, byte* DK) {
}
*/
- cout<<IDAmat<<endl;
+ // cout<<IDAmat<<endl;
}
int full=0;
int q=2;
- int n=4;
+ int n=8;
int k=4;
int Tb=64;
int l=10;//399*Tb;
else
M=readPartialFile(n,k,sizeFile,lc);
- // cout<<"M "<<endl;
- // cout<<M<<endl;
+ cout<<"M "<<endl;
+ cout<<M<<endl;
arma_rng::set_seed(time(NULL));
Cube<byte> IDAmat;
Cube<short> invIDAmat;
-
+
+
if(full)
{
IDAmat.resize(n,n,q);
Mat<byte> C;
Mat<char> 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<short> D=invIDAmat.slice(0)*C;
+ Mat<short> D=invIDAmat.slice(0)*C;
- mat A=conv_to<mat>::from(IDAmat.slice(0).submat(0,0,n-1,n-1));
+ /*mat A=conv_to<mat>::from(IDAmat.slice(0).submat(0,0,n-1,n-1));
mat B=conv_to<mat>::from(C.submat(0,0,n-1,lc-1));
mat D=solve(A,B);
- cout<<D<<endl;
+ */
D2=conv_to<Mat<char>>::from(D);
+ cout<<D2<<endl;
}
else {
- mat A=conv_to<mat>::from(IDAmat.slice(0).submat(0,0,n-1,k-1));
- mat B=conv_to<mat>::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<mat>::from(IDAmat.slice(0).submat(0,0,k-1,k-1));
+
+ mat B=conv_to<mat>::from(C.submat(0,0,k-1,lc-1));
mat D=solve(A,B);
+// mat D=inv(A)*B;
- cout<<D<<endl;
- D2=conv_to<Mat<char>>::from(D);
+// cout<<D<<endl;
+
+// Mat<short> D=invIDAmat.slice(0)*C.submat(0,0,k-1,lc-1);
+
+ D2=conv_to<Mat<char>>::from(D);
+ cout<<D2<<endl;
}