本文整理汇总了C++中Matrice::Print方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrice::Print方法的具体用法?C++ Matrice::Print怎么用?C++ Matrice::Print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrice
的用法示例。
在下文中一共展示了Matrice::Print方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvMatrix
void DrImage::ConvMatrix(){
double Average = 0.;
double Count = 0.;
Matrice ImIn(NWidth,NHeight);
for(int h=0;h<NHeight;h++){
for(int w=0;w<NWidth;w++){
double Sum = 1.- .3333*(data[0][h*NWidth+w]+data[1][h*NWidth+w]+data[2][h*NWidth+w]);
//double Sum = 1. - (data[0][h*NWidth+w]+data[1][h*NWidth+w]+data[2][h*NWidth+w]);
ImIn.Set(w,h,Sum);
Average += Sum;
Count += 1.;
}
}
Average /= Count;
//---------Canny---------------------
Matematica *Mat = new Matematica;
Matrice Canny(5,5);
Canny.FillCanny();
Canny.Print();
// Mat->ApplyFilter(&ImIn,&Canny);
// Mat->ApplyFilter(&ImIn,&Canny);
//-----------Edge-------------------
SPLINE Weight;
Weight.a0 = 0.;
Weight.a1 = 1.; Weight.a2 = 0.;
Weight.a3 = 0.; Weight.a4 = 0.;
Matrice *Mask = new Matrice(Weight,3);
Mask->Print();
//Mat->ApplyFilter(&ImIn,Mask);
// Mask->Transpose();
// Mat->ApplyFilter(ImIn,Mask);
//-------------Smooth----------------
const int NMatSize = 5;
Matrice GaussEdge(NMatSize,NMatSize);
GaussEdge.FillGaussian(.5,1.);
//double LatPos[5] = {.125,-.25,0.,.25,-.125};
// double LatPos[3] = {-1.,0.,1.};
// for(int w=0;w<NMatSize;w++){
// for(int h=0;h<NMatSize;h++){
// GaussEdge.Set(w,h,GaussEdge.Val(w,h)*LatPos[w]);
// }
// }
GaussEdge.Print();
//Mat->ApplyFilter(ImIn,&GaussEdge);
Matrice GaussSmooth(5,5);
GaussSmooth.FillGaussian(.5,3.);
// Mat->ApplyFilter(ImIn,&GaussSmooth);
//------------PixDev------------------
for(int h=0;h<NHeight;h++){
for(int w=0;w<NWidth;w++){
ImIn.Set(w,h,Average-ImIn.Val(w,h));
}
}
int PixelDev = 5;
double ValStep[3] = {0.,0.,0.};
int ValNStep[3] = {0,0,0};
for(int h=0;h<NHeight;h++){
for(int w=0;w<NWidth;w++){
ValNStep[0] = w - PixelDev;
if(ValNStep[0] < 0 ) continue;
if(ValNStep[0] >= NWidth) continue;
ValNStep[1] = w;
ValNStep[2] = w + PixelDev;
if(ValNStep[2] < 0 ) continue;
if(ValNStep[2] >= NWidth) continue;
for(int d=0;d<3;d++){
ValStep[d] = ImIn.Val(ValNStep[d],h);
if(d == 1){
ValStep[d] = ValStep[d] > 0. ? ValStep[d] : 0.;
continue;
}
ValStep[d] = ValStep[d] < 0. ? -ValStep[d] : 0.;
}
double Resp = ValStep[0]*ValStep[1]*ValStep[2];
//double Resp = ValStep[1];
//ImIn.Set(w,h,Resp);
}
}
char cImage[160];
sprintf(cImage,"Canny.png");
pngwriter ImageOut(NWidth,NHeight,1.0,cImage);
FILE *Ciccia = fopen("Pos3d.dat","w");
double NormH = 1./(double)NHeight;
double NormW = 1./(double)NWidth;
for(int h=0;h<NHeight;h++){
for(int w=0;w<NWidth;w++){
fprintf(Ciccia,"%lf %lf %lf\n",w*NormH,h*NormH,ImIn.Val(w,h));
ImageOut.plot(w,h,ImIn.Val(w,h),ImIn.Val(w,h),ImIn.Val(w,h));
}
}
fclose(Ciccia);
ImageOut.close();
}
示例2: FillMatrix
void Forces::FillMatrix(){
if(!IfFillMatrix) return;
IntMatrix->Clear();
double Inter = pEdge(CLat1)/(double)NEdge;//fabs(pPos(1,0) - pPos(0,0));
SPLINE Weight;
Weight.a0 = Kf.El[2];
Weight.a1 = 0./Inter;
Weight.a2 = Kf.Lap/SQR(Inter);
Weight.a3 = 0./(Inter*SQR(Inter));
Weight.a4 = Kf.SLap/(SQR(Inter)*SQR(Inter));
if(VAR_IF_TYPE(SysShape,SYS_ROD)){
int NDim = 1;
Matrice *CoeffMatrix = new Matrice(Weight,NDim);
CoeffMatrix->Print();
for(int r=0;r<pNPart();r++){
if(Pm[r].Typ != 0){ IntMatrix->Set(r,r,1.);continue;}
if(r >= 2) IntMatrix->Set(r,r-2,CoeffMatrix->Val(2,0));
if(r >= 1) IntMatrix->Set(r,r-1,CoeffMatrix->Val(2,1));
if(r < pNPart()-1) IntMatrix->Set(r,r+1,CoeffMatrix->Val(2,3));
if(r < pNPart()-2) IntMatrix->Set(r,r+2,CoeffMatrix->Val(2,4));
IntMatrix->Set(r,r,CoeffMatrix->Val(2,2));
}
IntMatrix->Invert();
//IntMatrix->Print();
delete CoeffMatrix;
}
else if(VAR_IF_TYPE(SysShape,SYS_LEAVES)){
int NDim = 1;
Matrice *CoeffMatrix = new Matrice(Weight,NDim);
CoeffMatrix->Print();
for(int r=0;r<pNPCh();r++){
if(Pm[r].Typ != 0){ IntMatrix->Set(r,r,1.);continue;}
if(r >= 2) IntMatrix->Set(r,r-2,CoeffMatrix->Val(2,0));
if(r >= 1) IntMatrix->Set(r,r-1,CoeffMatrix->Val(2,1));
if(r < pNPart()-1) IntMatrix->Set(r,r+1,CoeffMatrix->Val(2,3));
if(r < pNPart()-2) IntMatrix->Set(r,r+2,CoeffMatrix->Val(2,4));
IntMatrix->Set(r,r,CoeffMatrix->Val(2,2));
}
//IntMatrix->Invert();
IntMatrix->Print();
delete CoeffMatrix;
}
else if(VAR_IF_TYPE(SysShape,SYS_2D)){
int NDim = 2;
Matrice *CoeffMatrix = new Matrice(Weight,NDim);
CoeffMatrix->Print();
for(int p=0;p<pNPart();p++){
if(Pm[p].Typ != 0){
IntMatrix->Set(p,p,1.);
continue;
}
int pym1 = Ln[p].Link[0];
int pyp1 = Ln[p].Link[1];
int pym2 = Ln[pym1].Link[0];
int pyp2 = Ln[pyp1].Link[1];
int pxm1 = Ln[p].Link[2];
int pxp1 = Ln[p].Link[3];
int pxm2 = Ln[pxm1].Link[2];
int pxp2 = Ln[pxp1].Link[3];
// printf("%d)\n",p);
//printf("%d %d %d %d\n",pym2,pym1,pyp1,pyp2);
// printf("%d %d %d %d\n",pxm2,pxm1,pxp1,pxp2);
if(PeriodicImage[0]){
IntMatrix->Set(p,pxm2,CoeffMatrix->Val(2,0));
IntMatrix->Set(p,pxm1,CoeffMatrix->Val(2,1));
IntMatrix->Set(p,pxp1,CoeffMatrix->Val(2,3));
IntMatrix->Set(p,pxp2,CoeffMatrix->Val(2,4));
}
else{
if(pxm2 == p-2*nEdge[1])
IntMatrix->Set(p,pxm2,CoeffMatrix->Val(2,0));
if(pxm1 == p-nEdge[1])
IntMatrix->Set(p,pxm1,CoeffMatrix->Val(2,1));
if(pxp1 == p+nEdge[1])
IntMatrix->Set(p,pxp1,CoeffMatrix->Val(2,3));
if(pxp2 == p+2*nEdge[1])
IntMatrix->Set(p,pxp2,CoeffMatrix->Val(2,4));
}
IntMatrix->Add(p,p,CoeffMatrix->Val(2,2));
if(PeriodicImage[1]){
IntMatrix->Set(p,pym2,CoeffMatrix->Val(2,0));
IntMatrix->Set(p,pym1,CoeffMatrix->Val(2,1));
IntMatrix->Set(p,pyp1,CoeffMatrix->Val(2,3));
IntMatrix->Set(p,pyp2,CoeffMatrix->Val(2,4));
}
else{
if(pym2 == p-2)
IntMatrix->Set(p,pym2,CoeffMatrix->Val(2,0));
if(pym1 == p-1)
IntMatrix->Set(p,pym1,CoeffMatrix->Val(2,1));
if(pyp1 == p+1)
IntMatrix->Set(p,pyp1,CoeffMatrix->Val(2,3));
if(pyp2 == p+2)
IntMatrix->Set(p,pyp2,CoeffMatrix->Val(2,4));
}
}
IntMatrix->Invert();
//IntMatrix->Print();
delete CoeffMatrix;
}
//.........这里部分代码省略.........