You are on page 1of 13

macierz dodawanie cout<<x.

m(i,j)<<"'";
cout<<endl;
#include <cstdlib> #include <cstdlib> }
#include <iostream> #include <iostream> }
#include <time.h> #include <time.h>
int main(int argc, char *argv[])
using namespace std; using namespace std; {
macierz m(9,9);
class macierz class macierz print (m);
{private: {private: system("PAUSE");
int w; int k; float**t; int w; int k; float**t; return EXIT_SUCCESS;
public: public: }
macierz(int w1, int k1) macierz(int w1, int k1)
{w=w1; k=k1; t=new float*[w]; {w=w1; k=k1; t=new float*[w];
for (int i=0;i<w;++i) for (int i=0;i<w;++i)
t[i]=new float[k]; t[i]=new float[k];
for (int i=0;i<w;++i) for (int i=0;i<w;++i)
for (int j=0;j<k;++j) for (int j=0;j<k;++j)
t[i][j]=rand()%5;} t[i][j]=rand()%5;}

int W() {return w;}; int W() {return w;};
int K() {return k;} int K() {return k;}
float m (int i, int j) float m (int i, int j)
{return t[i][j];} {return t[i][j];}
};
void print (macierz x) void m1 (float x, int i, int j)
{for (int i=0;i<x.W();++i) {t[i][j]=x;
{for (int j=0;j<x.K();++j) }
cout<<x.m(i,j)<<"'"; };
cout<<endl; macierz suma (macierz x, macierz y)
}} {if ((x.W()==y.W())&&(x.K()==y.K()))
int main(int argc, char *argv[]) { macierz wynik (x.W(),x.K());
{ for(int i=0;i<x.W();++i)
macierz m(9,9); for(int j=0;j<x.K();++j)
print (m); wynik.m1(x.m(i,j)+y.m(i,j),i,j);
system("PAUSE"); return wynik;}}
return EXIT_SUCCESS; void print (macierz x)
} {for (int i=0;i<x.W();++i)
{for (int j=0;j<x.K();++j)
odejmowanie mnozenie przez liczbe #include <cstdlib>
#include <iostream>
#include <cstdlib> #include <cstdlib> #include <time.h>
#include <iostream> #include <iostream>
#include <time.h> #include <time.h> using namespace std;
using namespace std; using namespace std; class macierz
class macierz class macierz {private:
{private: {private: int w; int k; float**t;
int w; int k; float**t; int w; int k; float**t; public:
public: public: macierz(int w1, int k1)
macierz(int w1, int k1) macierz(int w1, int k1) {w=w1; k=k1; t=new float*[w];
{w=w1; k=k1; t=new float*[w]; {w=w1; k=k1; t=new float*[w]; for(int i=0; i<w; ++i) t[i]=new float [k];
for (int i=0;i<w;++i) for (int i=0;i<w;++i) for(int i=0; i<w; ++i)
t[i]=new float[k]; t[i]=new float[k]; for(int j=0; j<k; ++j) t[i][j]=rand()%5;
for (int i=0;i<w;++i) for (int i=0;i<w;++i) };int W()
for (int j=0;j<k;++j) for (int j=0;j<k;++j) {return w;
t[i][j]=rand()%5;} t[i][j]=rand()%5;} };int K()
int W() {return w;}; {return k;
int W() {return w;}; int K() {return k;} };float m(int i, int j)
int K() {return k;} float m (int i, int j) {return t[i][j];
float m (int i, int j) {return t[i][j];} };~macierz()
{return t[i][j];} void m1 (float x, int i, int j) {delete []t;
void m1 (float x, int i, int j) {t[i][j]=x; }}; };};int main(int argc, char *argv[])
{t[i][j]=x; } }; macierz mnozenie (macierz x, float z) {system("PAUSE");
macierz suma (macierz x, macierz y) { macierz wynik (x.W(),x.K()); return EXIT_SUCCESS;}
{if ((x.W()==y.W())&&(x.K()==y.K())) for(int i=0;i<x.W();++i)
{ macierz wynik (x.W(),x.K()); for(int j=0;j<x.K();++j)
for(int i=0;i<x.W();++i) wynik.m1(x.m(i,j)*z,i,j); //mnozenie przez liczbe
for(int j=0;j<x.K();++j) return wynik;}
wynik.m1(x.m(i,j)-y.m(i,j),i,j); //error void print (macierz x)
}} void print (macierz x) {for (int i=0;i<x.W();++i)
{for (int i=0;i<x.W();++i) {for (int j=0;j<x.K();++j)
{for (int j=0;j<x.K();++j) cout<<x.m(i,j)<<"'";
cout<<x.m(i,j)<<"'"; cout<<endl;}}
cout<<endl; } } int main(int argc, char *argv[])
int main(int argc, char *argv[]) { macierz m(9,9);
{ macierz m(9,9); print (m); print (m);
system("PAUSE"); system("PAUSE"); return EXIT_SUCCESS;
return EXIT_SUCCESS; } }
include <cstdlib> #include <cstdlib> transponowanie macierzy
#include <iostream> #include <iostream> #include <cstdlib>
#include <time.h> #include <time.h> #include <iostream>
using namespace std; #include <time.h>
using namespace std; class macierz using namespace std;
class macierz {private: class macierz
{ int w; int k; float**t; {private: int w; int k; float**t;
private: public: public: macierz(int w1, int k1)
int w; int k; float**t; macierz(int w1, int k1) {w=w1; k=k1; t=new float*[w];
public: {w=w1; k=k1; t=new float*[w]; for (int i=0;i<w;++i)
macierz(int w1, int k1) for(int i=0; i<w; ++i) t[i]=new float [k]; t[i]=new float[k];
{ for(int i=0; i<w; ++i) for (int i=0;i<w;++i)
w=w1; k=k1; t=new float*[w]; for(int j=0; j<k; ++j) t[i][j]=rand()%5;}; for (int j=0;j<k;++j)
for(int i=0; i<w; ++i) t[i]=new float [k]; int W() {return w;}; t[i][j]=rand()%5;}
for(int i=0; i<w; ++i) int K() {return k;}; int W() {return w;};
for(int j=0; j<k; ++j) t[i][j]=rand()%5; float m(int i, int j) int K() {return k;}
}; {return t[i][j];}; float m (int i, int j)
int W() void m1(float x, int i, int j) {return t[i][j];}
{return w;}; {t[i][j]=x;}}; void m1 (float x, int i, int j)
int K() macierz suma (macierz x, macierz y) {t[i][j]=x; }};
{return k;}; {if((x.W()==y.W())&&(x.K()==y.K())) macierz t (macierz x)
float m(int i, int j) {macierz wynik(x.W(),y.K()); { macierz wynik (x.K(),x.W());
{return t[i][j];}; for(int i=0; i<x.W(); ++i) for(int i=0;i<x.K();++i)
~macierz() for(int j=0; j<x.K(); ++j) for(int j=0;j<x.W();++j)
{delete []t;};}; wynik.m1(x.m(i,j)+y.m(i,j),i,j); wynik.m1(x.m(j,i),i,j);return wynik;
void print(macierz m) return wynik;}}; }void print (macierz x)
{for(int i=0; i<m.W(); ++i) void print(macierz m) {for (int i=0;i<x.W();++i)
{for(int j=0; j<m.K(); j++) {for(int i=0; i<m.W(); ++i) {for (int j=0;j<x.K();++j)
cout<<m.m(i,j)<<","; {for(int j=0; j<m.K(); ++j) cout<<x.m(i,j)<<"'";
cout<<endl;}}; cout<<m.m(i,j)<<","; cout<<endl;}}
int main(int argc, char *argv[]) cout<<endl;}}; int main(int argc, char *argv[])
{macierz m(3,5); int main(int argc, char *argv[]) { macierz m(6,3);
print(m); {macierz m1(3,2); macierz m3=t (m);
system("PAUSE"); macierz m2(3,2); print (m);
return EXIT_SUCCESS; macierz m3=suma(m1,m2); cout<<endl;
} print(m3); print (m3);
system("PAUSE"); system("PAUSE");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
#include <cstdlib> #include <cstdlib> macierz z (2,2);
#include <iostream> #include <iostream> z=il(z,y);
#include <time.h> #include <time.h> print (x);
using namespace std; using namespace std; cout<<endl;
class macierz class macierz print (y);
{private: int w; int k; float**t; {private: cout<<endl;
public: macierz(int w1, int k1) int w; int k; float**t; print (z);
{w=w1; k=k1; t=new float*[w]; public: cout<<endl;
for (int i=0;i<w;++i) macierz(int w1, int k1) system("PAUSE");
t[i]=new float[k]; {w=w1; k=k1; t=new float*[w]; return EXIT_SUCCESS;
for (int i=0;i<w;++i) for (int i=0;i<w;++i) }
for (int j=0;j<k;++j) t[i]=new float[k];
t[i][j]=rand()%5;} for (int i=0;i<w;++i)
int W() {return w;}; for (int j=0;j<k;++j)
int K() {return k;} t[i][j]=rand()%5;}
float m (int i, int j) int W() {return w;};
{return t[i][j];} int K() {return k;}
void m1 (float x, int i, int j) float m (int i, int j)
{t[i][j]=x; }}; {return t[i][j];}
macierz il (macierz x, macierz y) void m1 (float x, int i, int j)
{if (x.K()==x.W()) {t[i][j]=x; }};
{macierz w(x.W(),y.K()); macierz il (macierz x, macierz y)
for(int i=0;i<x.W();i++) {if (x.K()==x.W())
for(int j=0;j<y.K();j++) { macierz w(x.W(),y.K());
{float t=0; for(int i=0;i<x.W();i++)
for (int k=0; k<x.K();++k) for(int j=0;j<y.K();j++)
t=t+x.m(i,k)*y.m(k,j); w.m1(t,i,j);}}; {float t=0;
}void print (macierz x) for (int k=0; k<x.K();++k)
{for (int i=0;i<x.W();++i) t=t+x.m(i,k)*y.m(k,j); w.m1(t,i,j);};
{for (int j=0;j<x.K();++j) return w;}}
cout<<x.m(i,j)<<"'"; void print (macierz x)
cout<<endl;}} {for (int i=0;i<x.W();++i)
int main(int argc, char *argv[]) {for (int j=0;j<x.K();++j)
{ macierz x(6,6); macierz y(6,6); macierz z cout<<x.m(i,j)<<"|";
(6,6); z=il(z,y); print (x); cout<<endl;}}
cout<<endl; print (y); int main(int argc, char *argv[])
cout<<endl; print (z); cout<<endl; {srand(time(NULL));
system("PAUSE"); macierz x(2,2);
return EXIT_SUCCESS;} macierz y(2,2);
potega macierzy z=il(z,x); #include <cstdlib>
return z;}; #include <iostream>
#include <cstdlib> void print (macierz x) #include <time.h>
#include <iostream> {for (int i=0;i<x.W();++i) using namespace std;
#include <time.h> {for (int j=0;j<x.K();++j) class macierz
using namespace std; cout<<x.m(i,j)<<"|"; {private:
class macierz cout<<endl;}} int w; int k; float**t;
{private: int main(int argc, char *argv[]) public:
int w; int k; float**t; { srand(time(NULL)); macierz(int w1, int k1)
public: macierz x(2,2); {w=w1; k=k1; t=new float*[w];
macierz(int w1, int k1) macierz z(2,2); for(int i=0; i<w; ++i) t[i]=new float [k];
{w=w1; k=k1; t=new float*[w]; z=potega(x,2); for(int i=0; i<w; ++i)
for (int i=0;i<w;++i) print (x); for(int j=0; j<k; ++j) t[i][j]=rand()%5;};
t[i]=new float[k]; cout<<endl; int W()
for (int i=0;i<w;++i) print (z); {return w;};
for (int j=0;j<k;++j) cout<<endl; int K()
t[i][j]=rand()%5;} cout<<endl; {return k;};
int W() {return w;}; system("PAUSE"); float m(int i, int j)
int K() {return k;} return EXIT_SUCCESS; {return t[i][j];};
float m (int i, int j) } void m1(float x, int i, int j)
{return t[i][j];} {t[i][j]=x;} };
void m1 (float x, int i, int j) macierz suma (macierz x, macierz y)
{t[i][j]=x; }}; {
macierz il (macierz x, macierz y) if((x.W()==y.W())&&(x.K()==y.K()))
{if (x.K()==x.W()) {
{macierz w(x.W(),y.K()); macierz wynik(x.W(),y.K());
for(int i=0;i<x.W();i++) for(int i=0; i<x.W(); ++i)
for(int j=0;j<y.K();j++) for(int j=0; j<x.K(); ++j)
{float t=0; wynik.m1(x.m(i,j)+y.m(i,j),i,j);
for (int k=0; k<x.K();++k) return wynik;}};
t=t+x.m(i,k)*y.m(k,j); w.m1(t,i,j);}; macierz trans(macierz x)
return w;}} {macierz wynik(x.K(),x.W());
macierz potega (macierz x, int n) for(int i=0; i<x.K(); ++i)
{macierz z(x.K(),x.W()); for(int j=0; j<x.W(); ++j)
for(int i=0;i<x.W();++i) wynik.m1(x.m(j,i),i,j);
for(int j=0;j<x.K();++j) return wynik;
if(i==j) z.m1(1,i,i); };
else z.m1(0,i,j); macierz il(macierz x, macierz y)
for (int i=0; i<n;++i) {if(x.W()==y.K())
{macierz z(x.W(),y.K()); macierz z(2,2); {if (x.K()==x.W())
for(int i=0; i<x.W(); ++i) z=il(x,y); {macierz w(x.W(),y.K());
for(int j=0; j<x.K(); ++j) print(x); for(int i=0;i<x.W();i++)
{float t=0; print(y); for(int j=0;j<y.K();j++)
for(int k=0; k<x.K(); ++k) print(z); {float t=0;
t=x.m(i,k)*y.m(k,j)+t; cout<<endl; for (int k=0; k<x.K();++k)
z.m1(t,i,j);}return z;}}; z=potega(x,2); t=t+x.m(i,k)*y.m(k,j); w.m1(t,i,j);};
macierz potega (macierz x, int n) print(x); return w;}
{macierz z(z.W(), x.K()); print(z); }
for(int i=0; i<x.W(); ++i) cout<<endl; void print (macierz x)
for(int j=0; j<x.K(); ++j) system("PAUSE"); {for (int i=0;i<x.W();++i)
if(i==j) return EXIT_SUCCESS; {for (int j=0;j<x.K();++j)
z.m1(1,i,i); } cout<<x.m(i,j)<<"|";
else cout<<endl;}}
z.m1(0,i,j); ostream & operator<<(ostream &w, macierz m)
for(int i=0; i<n; ++i) {for (int i=0; i<m.W();++i)
z=il(z,x); //z=z*x 1. {for (int j=0; j<m.K();++j)
return z; #include <cstdlib> w<<m.m(i,j)<<"|";w<<endl;}return w;}
} #include <iostream> int main(int argc, char *argv[])
void print(macierz m) #include <time.h> { srand(time(NULL));
{for(int i=0; i<m.W(); ++i) using namespace std; macierz x(2,2);
{for(int j=0; j<m.K(); ++j) class macierz macierz y(2,2);
cout<<m.m(i,j)<<","; {private: macierz z (2,2);
cout<<endl;}}; int w; int k; float**t; z=il(x,y);
public: print (x);
int main(int argc, char *argv[]) macierz(int w1, int k1) cout<<endl;
{macierz m1(3,2); {w=w1; k=k1; t=new float*[w]; print (y);
macierz m2(3,2); for (int i=0;i<w;++i) cout<<endl;
macierz m3=suma(m1,m2); t[i]=new float[k]; print (z);
print(m3); for (int i=0;i<w;++i) cout<<endl;
cout<<endl; for (int j=0;j<k;++j) system("PAUSE");
print(m2); t[i][j]=rand()%5;} return EXIT_SUCCESS;
cout<<endl; int W() {return w;}; }
macierz m4=trans(m2); int K() {return k;}
print(m4); float m (int i, int j)
cout<<endl; {return t[i][j];}
void m1 (float x, int i, int j)
macierz x(2,2); {t[i][j]=x; }};
macierz y(2,2); macierz il (macierz x, macierz y)
ostream & operator<<(ostream &w, macierz m) for(int i=0; i<w; ++i)
{for (int i=0; i<m.W();++i) for(int j=0; j<k; ++j) t[i][j]=rand()%5;};
2. 2. {for (int j=0; j<m.K();++j) int W()
#include <cstdlib> w<<m.m(i,j)<<"|"; {return w;};
#include <iostream> w<<endl;}return w;} int K()
#include <time.h> int main(int argc, char *argv[]) {return k;};
using namespace std; { srand(time(NULL)); float m(int i, int j)
class macierz macierz x(2,2); macierz y(2,2); macierz z {return t[i][j];};
{private: (2,2); macierz m (2,2); macierz w (2,2); void m1(float x, int i, int j)
int w; int k; float**t; z=il(x,y); {t[i][j]=x;}; };
public: print (x); macierz suma (macierz x, macierz y)
macierz(int w1, int k1) cout<<endl; {if((x.W()==y.W())&&(x.K()==y.K()))
{w=w1; k=k1; t=new float*[w]; print (y); {macierz wynik(x.W(),y.K());
for (int i=0;i<w;++i) cout<<endl; for(int i=0; i<x.W(); ++i)
t[i]=new float[k]; print (z); for(int j=0; j<x.K(); ++j)
for (int i=0;i<w;++i) cout<<endl; wynik.m1(x.m(i,j)+y.m(i,j),i,j);
for (int j=0;j<k;++j) print (w); return wynik;}};
t[i][j]=rand()%5;} cout<<endl; macierz trans(macierz x)
int W() {return w;}; print (m); {macierz wynik(x.K(),x.W());
int K() {return k;} for(int i=0; i<x.K(); ++i)
float m (int i, int j) system("PAUSE"); for(int j=0; j<x.W(); ++j)
{return t[i][j];} return EXIT_SUCCESS; wynik.m1(x.m(j,i),i,j);
void m1 (float x, int i, int j) } return wynik;};
{t[i][j]=x; }}; macierz il(macierz x, macierz y)
macierz il (macierz x, macierz y) {if(x.W()==y.K())
{if (x.K()==x.W()) ++ {macierz z(x.W(),y.K());
{macierz w(x.W(),y.K()); for(int i=0; i<x.W(); ++i)
for(int i=0;i<x.W();i++) #include <cstdlib> for(int j=0; j<x.K(); ++j)
for(int j=0;j<y.K();j++) #include <iostream> {float t=0;
{float t=0; #include <time.h> for(int k=0; k<x.K(); ++k)
for (int k=0; k<x.K();++k) using namespace std; t=x.m(i,k)*y.m(k,j)+t;
t=t+x.m(i,k)*y.m(k,j); w.m1(t,i,j);}; class macierz z.m1(t,i,j);}
return w;}} { return z;}};
void print (macierz x) private: macierz potega (macierz x, int n)
{for (int i=0;i<x.W();++i) int w; int k; float**t; {macierz z(z.W(), x.K());
{for (int j=0;j<x.K();++j) public: for(int i=0; i<x.W(); ++i)
cout<<x.m(i,j)<<"|"; macierz(int w1, int k1) for(int j=0; j<x.K(); ++j)
cout<<endl;} } {w=w1; k=k1; t=new float*[w]; if(i==j)
for(int i=0; i<w; ++i) t[i]=new float [k]; z.m1(1,i,i);
else {float t=0;
z.m1(0,i,j); for(int k=0; k<x.K(); ++k)
for(int i=0; i<n; ++i) t=x.m(i,k)*y.m(k,j)+t;
z=il(z,x); //z=z*x z.m1(t,i,j);}return z;}};
return z;}; #include <cstdlib> macierz potega (macierz x, int n)
void print(macierz m) #include <iostream> {macierz z(z.W(), x.K());
{for(int i=0; i<m.W(); ++i) #include <time.h> for(int i=0; i<x.W(); ++i)
{for(int j=0; j<m.K(); ++j) using namespace std; for(int j=0; j<x.K(); ++j)
cout<<m.m(i,j)<<"|"; class macierz if(i==j)
cout<<endl;}}; {private: int w; int k; float**t; z.m1(1,i,i);
ostream&operator<<(ostream&w, macierz m) public: macierz(int w1, int k1) else
{for(int i=0; i<m.W(); ++i) {w=w1; k=k1; t=new float*[w]; z.m1(0,i,j);
{for(int j=0; j<m.K(); ++j) for(int i=0; i<w; ++i) t[i]=new float [k]; for(int i=0; i<n; ++i)
w<<m.m(i,j)<<"|"; for(int i=0; i<w; ++i) z=il(z,x); //z=z*x
w<<endl;}return w;}; for(int j=0; j<k; ++j) t[i][j]=rand()%5;}; return z;};
macierz operator *(macierz x, macierz y) int W() {return w;}; void print(macierz m)
{return il(x,y);}; int K() {return k;}; {for(int i=0; i<m.W(); ++i)
macierz operator +(macierz x, macierz y) float m(int i, int j) {for(int j=0; j<m.K(); ++j)
{return suma(x,y);}; {return t[i][j];}; cout<<m.m(i,j)<<"|";
int main(int argc, char *argv[]) void m1(float x, int i, int j) cout<<endl;}};
{macierz m(2,2); {t[i][j]=x;}; }; ostream&operator<<(ostream&w, macierz m)
macierz w(2,2); macierz suma (macierz x, macierz y) {for(int i=0; i<m.W(); ++i)
macierz z(2,2); {if((x.W()==y.W())&&(x.K()==y.K())) {for(int j=0; j<m.K(); ++j)
cout<<m<<endl; {macierz wynik(x.W(),y.K()); w<<m.m(i,j)<<"|";
cout<<il(m,w)<<endl; for(int i=0; i<x.W(); ++i) w<<endl;}return w;};
cout<<m*w<<endl; for(int j=0; j<x.K(); ++j) macierz operator *(macierz x, macierz y)
cout<<(m+w+z)*z<<endl; wynik.m1(x.m(i,j)+y.m(i,j),i,j); {return il(x,y);};
system("PAUSE"); return wynik;}}; macierz operator +(macierz x, macierz y)
return EXIT_SUCCESS; macierz trans(macierz x) {return suma(x,y);};
} {macierz wynik(x.K(),x.W()); macierz operator ^(macierz x, int n)
for(int i=0; i<x.K(); ++i) {return potega(x,n);};
for(int j=0; j<x.W(); ++j) int main(int argc, char *argv[])
wynik.m1(x.m(j,i),i,j); {macierz m(2,2);
return wynik;}; macierz w(2,2);
macierz il(macierz x, macierz y) macierz z(2,2);
{if(x.W()==y.K()) cout<<m<<endl;
{macierz z(x.W(),y.K()); cout<<il(m,w)<<endl;
for(int i=0; i<x.W(); ++i) cout<<m*w<<endl;
for(int j=0; j<x.K(); ++j) cout<<(m+w+z)*z<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
#include <cstdlib> macierz wynik(x.W(), x.K()); int main(int argc, char *argv[])
#include <iostream> for(int i=0; i<x.W(); ++i) { macierz m(2,2);
#include <time.h> for(int j=0; j<x.K(); ++j) macierz w(2,2);
wynik.m1(x.m(i,j)*t,i,j); return wynik;}; macierz z(2,2);
using namespace std; macierz T(macierz x) cout<<((z*3+w+m*2)^10);
class macierz{ {macierz wynik(x.K(), x.W()); //srand(time(NULL));
private: for(int i=0; i<x.K(); ++i) //macierz x(10,10);
int w; // wiesze for(int j=0; j<x.W(); ++j) //print (x);
int k; // kolumny wynik.m1(x.m(i,j),j,i); return wynik;};
float **t; // tablica wskazników macierz il(macierz x, macierz y){ //cout<<"----------------------------------------------"<<
public: if (x.K()==y.W()){ endl;
macierz(int w1, int k1){ macierz W(x.W(), y.K()); //macierz z(10,10);
w=w1; k=k1; for( int i=0; i<x.W(); ++i) //z = potega(x,3);
t=new float*[w]; for( int j=0; j<x.K(); ++j){ //print (z);
for(int i=0;i<w;++i) float t=0;
t[i]=new float[k]; for(int k=0;k<x.K(); ++k) //cout<<"----------------------------------------------"<<
for(int i=0;i<w;++i) t=t+x.m(i,k)*y.m(k,j); endl;
for(int j=0;j<k;++j) W.m1(t,i,j); };return W;}}; system("PAUSE");
t[i][j]=rand()%6; } macierz potega(macierz x, int n){ return EXIT_SUCCESS;
int W(){ return w; }; macierz Z(x.K(),x.W()); }
int K(){ return k; }; for(int i = 0; i<x.W(); ++i)
float m(int i, int j){ for(int j=0; j<x.K(); ++j)
return t[i][j]; }; if(i==j) Z.m1(1,i,i);
void m1(float x, int i, int j){ else Z.m1(0,i,j);
t[i][j]=x; };}; for(int i=0; i<n; ++i)
void print(macierz x){ Z=il(Z,x); return Z;};
for(int i=0;i<x.W();++i){ ostream & operator<<(ostream & w, macierz m)
for(int j=0;j<x.K();++j) { for ( int i=0; i<m.W(); ++i){
cout<<x.m(i,j)<<"|"; for(int j=0; j<m.K(); ++j)
cout<<endl; }}; w<<m.m(i,j)<<"|";
macierz suma(macierz x, macierz y){ w<<endl; } return w;};
if((x.W()==y.W())&&(x.K()==y.K())){ //macierz operator *(macierz x, macierz y){//
macierz wynik(x.W(), x.K()); return il(x,y);//};
for(int i=0; i<x.W(); ++i) macierz operator +(macierz x, macierz y){
for(int j=0; j<x.K(); ++j) return suma(x,y);};
wynik.m1(x.m(i,j)+y.m(i,j),i,j); return wynik; macierz operator ^(macierz x, int n){
}}; return potega(x,n);};
macierz mn(macierz x, float t){ macierz operator *(macierz x, float t){
return mn(x,t);};
for(int j=0;j<x.K();++j) {for (int j=0;j<x.K();++j)
#include <cstdlib> if(i==j) z.m1(1,i,i); cout<<x.m(i,j)<<"|";
#include <iostream> else z.m1(0,i,j); cout<<endl;}}
#include <time.h> for (int i=0; i<n;++i)
using namespace std; z=il(z,x); return z;}; ostream& operator<<(ostream& W, macierz M)
class macierz {for (int i=0;i<M.W();++i)
{private: macierz suma (macierz x, macierz y) {for (int j=0;j<M.K();++j)
int w; int k; float**t; {if ((x.W()==y.W())&&(x.K()==y.K())) W<<M.m(i,j)<<"|";
public: { macierz wynik (x.W(),x.K()); W<<endl;}return W;}
macierz(int w1, int k1) for(int i=0;i<x.W();++i)
{w=w1; k=k1; t=new float*[w]; for(int j=0;j<x.K();++j) macierz operator *(macierz x, macierz y){return
for (int i=0;i<w;++i) wynik.m1(x.m(i,j)+y.m(i,j),i,j); il(x,y);};
t[i]=new float[k]; return wynik;}}
for (int i=0;i<w;++i) macierz operator +(macierz x, macierz y)
for (int j=0;j<k;++j) macierz odejmowanie (macierz x, macierz y) {return suma(x,y);};
t[i][j]=rand()%5;} {if ((x.W()==y.W())&&(x.K()==y.K()))
{ macierz wynik (x.W(),x.K()); macierz operator -(macierz x, macierz y)
int W() {return w;}; for(int i=0;i<x.W();++i) {return odejmowanie(x,y);};
int K() {return k;} for(int j=0;j<x.K();++j)
wynik.m1(x.m(i,j)-y.m(i,j),i,j); macierz operator ^(macierz x, int n)
float m (int i, int j) return wynik;}} {return potega (x,n);};
{return t[i][j];}
macierz mnozenie (macierz x, float z) macierz operator *(macierz x, float z)
void m1 (float x, int i, int j) //mnozenie przez liczbe {return mnozenie (x,z);};
{t[i][j]=x; }}; { macierz wynik (x.W(),x.K());
for(int i=0;i<x.W();++i) macierz operator ++(macierz x)
macierz il (macierz x, macierz y) for(int j=0;j<x.K();++j) {return t (x);};
{if (x.K()==x.W()) wynik.m1(x.m(i,j)*z,i,j);
{macierz w(x.W(),y.K()); return wynik;} int main(int argc, char *argv[])
for(int i=0;i<x.W();i++) { srand(time(NULL));
for(int j=0;j<y.K();j++) macierz t (macierz x) //transponowanie macierz m(2,2);
{float t=0; { macierz wynik (x.K(),x.W()); macierz w(2,2);
for (int k=0; k<x.K();++k) for(int i=0;i<x.K();++i) macierz z(2,2);
t=t+x.m(i,k)*y.m(k,j); w.m1(t,i,j);}; for(int j=0;j<x.W();++j) cout<<m<<endl;
return w;}} wynik.m1(x.m(j,i),i,j); cout<<w<<endl;
return wynik;} cout<<z<<endl;
macierz potega (macierz x, int n) cout<<++z<<endl;
{macierz z(x.K(),x.W()); void print (macierz x) system("PAUSE");
for(int i=0;i<x.W();++i) {for (int i=0;i<x.W();++i)
return EXIT_SUCCESS; znalezione for(int j=0; j<x.K();++j)
} { float t=0;
#include <cstdlib> for (int k=0; k<x.K();++k)
#include <iostream> t=x.M(i,k)*y.M(k,j)+t;
#include <time.h> z.m1(t,i,j);} return z;}};
using namespace std; /*macierz operator *(macierz x, macierz y)
class macierz { return il(x,y); };*/
{ private: macierz potega(macierz x, int n)
int w; int k; float**t; { macierz z(x.W(), x.K());
public: for(int i=0; i<x.W();++i)
void M(int i, int j, float x) for(int j=0; j<x.K(); ++j)
{ t[i][j]=x; } if (i==j) z.m1(1,i,i);
void m1(float x, int i, int j) else z.m1(0,i,j);
{ t[i][j]=x; } for(int i=0; i<n; ++i)
macierz(int w1, int k1) z=il(z,x); return z;};
{ w=w1; k=k1; macierz operator ^ (macierz x, int n)
t= new float*[w]; { return potega (x,n); }
for (int i=0; i<w; ++i) macierz suma(macierz x, macierz y)
t[i]= new float[k]; { if((x.W()==y.W())&&(x.K()==y.K()))
for(int i=0; i<w; ++i) { macierz wynik(y.W(), y.K());
for(int j=0; j<k; ++j) for(int i=0; i<x.W();++i)
t[i][j]=rand()%5;} for(int j=0; j<x.K();++j)
wynik.m1(x.M(i,j)+y.M(i,j), i, j); return
int W(){return w;};int K() wynik; } };
{ return k;}; macierz operator + (macierz x, macierz y)
float M(int i, int j) {return suma(x,y); }
{ return t[i][j];} }; macierz roznica(macierz x, macierz y)
void print(macierz m) { if((x.W()==y.W())&&(x.K()==y.K()))
{ for(int i=0; i<m.W();++i) { macierz wynik(y.W(), y.K());
{ for(int j=0; j<m.K();++j) for(int i=0; i<x.W();++i)
cout<<m.M(i,j)<<" | "; for(int j=0; j<x.K();++j)
cout<<endl; } }; wynik.m1(x.M(i,j)-y.M(i,j), i, j);
ostream& operator<<(ostream&W, macierz M) return wynik; } };
{ print(M); return W; }; macierz operator -(macierz x, macierz y)
{ return roznica(x,y); }
macierz il(macierz x, macierz y) macierz operator *(float y, macierz x)
{ if(x.W()==y.K()) { macierz W(x.W(), x.K());
{ macierz z(x.W(),y.K()); for(int i=0; i<x.W();++i)
for(int i=0; i<x.W(); ++i) for(int j=0; j<x.K(); ++j)
x.M(i,j, y* x.M(i,j));
return W;
};
macierz T(macierz x)
{ macierz wynik(x.K(), x.W());
for(int i=0; i<x.K();++i)
for(int j=0; j<x.W();++j)
wynik.m1(x.M(j,i), i, j);
return wynik;
};
macierz operator --(macierz m)
{
return T(m);
};

int main(int argc, char *argv[])
{
srand(time(NULL));
macierz M(3,3);
macierz S(2,2);

//cout<<M-S<<endl;

cout<<M<<endl;
//cout<<S<<endl;
//cout<<3*M<<endl;
//cout<<M+S;
//cout<<M<<endl;
//cout<<(M^2)<<endl;

cout<<--(3*M)<<endl;

//cout<<M*M<<endl;

system("PAUSE");
return EXIT_SUCCESS;
}