Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "UkladRownanLiniowych.hh"
- std::istream& operator >> (std::istream &Strm, UkladRownanLiniowych &UklRown)
- {
- Macierz a;
- Wektor b;
- Strm >> a;
- Strm >> b;
- UklRown.setU(a,b);
- return Strm;
- }
- std::ostream& operator << (std::ostream &Strm, const UkladRownanLiniowych &UklRown)
- {
- Strm <<"Macierz:" <<endl << UklRown.getM() <<endl <<"Wektor wyrazow wolnych:"<<endl << UklRown.getW() <<endl;
- return Strm;
- }
- Macierz UkladRownanLiniowych:: ZmienKolumnyX()
- {
- Macierz tmp;
- tmp = this->A;
- for(int i=0; i< ROZMIAR; i++)
- {
- tmp(0,i)=this->B[i];
- }
- return tmp;
- }
- Macierz UkladRownanLiniowych:: ZmienKolumnyY()
- {
- Macierz tmp;
- tmp = this->A;
- for(int i=0; i< ROZMIAR; i++)
- {
- tmp(1,i)=this->B[i];
- }
- return tmp;
- }
- Macierz UkladRownanLiniowych:: ZmienKolumnyZ()
- {
- Macierz tmp;
- tmp = this->A;
- for(int i=0; i< ROZMIAR; i++)
- {
- tmp(2,i)=this->B[i];
- }
- return tmp;
- }
- Wektor UkladRownanLiniowych:: rozwiaz()
- {
- Macierz tmp;
- Wektor rozw;
- double Wx,Wy,Wz,W;
- tmp = this->A;
- W = tmp.Wyznacznik();
- tmp = this->ZmienKolumnyX();
- Wx = tmp.Wyznacznik();
- tmp = this->ZmienKolumnyY();
- Wy = tmp.Wyznacznik();
- tmp = this -> ZmienKolumnyZ();
- Wz = tmp.Wyznacznik();
- if( W != 0)
- {
- rozw[0] = Wx/W;
- rozw[1] = Wy/W;
- rozw[2] = Wz/W;
- return rozw;
- }
- else if( W = 0 && (Wx !=0 || Wy !=0 || Wz !=0) )
- {
- cout << "Uklad sprzeczny. Brak rozwiazan" << endl;
- return rozw;
- }
- else
- {
- cout << "Uklad nieoznacznony. Nieskonczenie wiele rozwiazan" << endl;
- return rozw;
- }
- }
- Wektor UkladRownanLiniowych:: Wektorbledu(Wektor W)
- {
- Wektor Wynik;
- Wynik = (this -> A * W);
- Wynik = Wynik - this->B;
- return Wynik;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement