27 #include "../CImg/CImg.h"
28 using namespace cimg_library;
32 void matrixDisplay(
const CImg<T> &a);
34 CImg<T> matrixProduct(
const CImg<T> &a,
const CImg<T> &b);
41 void matrixDisplay(
const CImg<T> &a) {
43 int I(a.height()), J(a.width()), K(a.depth()), L(a.spectrum());
50 std::cout<<a(x,y)<<
"]\n";
52 else if(x%(J-1)==0&&x!=0){
53 std::cout<<a(x,y)<<
"]\n";
59 std::cout<<a(x,y)<<
"\t";
70 CImg<T> matrixProduct(
const CImg<T> &a,
const CImg<T> &b){
72 int Ia(a.height()), Ja(a.width()), Ka(a.depth()), La(a.spectrum());
73 int Ib(b.height()), Jb(b.width()), Kb(b.depth()), Lb(b.spectrum());
75 CImg<double> c(Jb, Ia, Ka, La, 0);
79 for (
int k=0; k<Ja; k++) {
80 c(x,y)+=(double)a(k,y)*(double)b(x,k);
86 throw CImgInstanceException(
"Error dimension: enter such a product A(i,j)xB(j,k)\n");