Herezh_dev/herezh_pp/tenseurs_mai99/Vecteurs/VeurPropre.cc

114 lines
3.3 KiB
C++
Raw Permalink Normal View History

#include "VeurPropre.h"
// This file is part of the Herezh++ application.
//
// The finite element software Herezh++ is dedicated to the field
// of mechanics for large transformations of solid structures.
// It is developed by Gérard Rio (APP: IDDN.FR.010.0106078.000.R.P.2006.035.20600)
// INSTITUT DE RECHERCHE DUPUY DE LÔME (IRDL) <https://www.irdl.fr/>.
//
// Herezh++ is distributed under GPL 3 license ou ultérieure.
//
// Copyright (C) 1997-2021 Université Bretagne Sud (France)
// AUTHOR : Gérard Rio
// E-MAIL : gerardrio56@free.fr
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// For more information, please consult: <https://herezh.irdl.fr/>.
// CONSTRUCTEURS :
// définition d'une instance qui ne contiend qu'une valeur propre
VeurPropre::VeurPropre() :
val(0)
{ pv = NULL;
};
// définition d'une instance qui contiend une valeur propre et
// un vecteur propre de dimension n
VeurPropre::VeurPropre(int n) :
val(0)
{ pv = new Vecteur (n);
};
// définition d'une instance à partir d'une valeur et d'un vecteur propre
VeurPropre::VeurPropre(double va,Vecteur v )
{ val = va;
pv = new Vecteur (v);
};
// constructeur de copie
VeurPropre::VeurPropre(const VeurPropre& a)
{ val = a.val;
if (a.pv == NULL)
pv = NULL;
else
pv = new Vecteur (*(a.pv));
};
// DESTRUCTEUR :
VeurPropre::~VeurPropre()
{ if (pv != NULL)
delete pv;
};
// surcharge de l'affectation
VeurPropre& VeurPropre::operator= (const VeurPropre& a)
{ val = a.val;
if (a.pv == NULL)
pv = NULL;
else
if (pv == NULL)
pv = new Vecteur (*(a.pv));
else
(*pv) = (*(a.pv));
return (*this);
};
// Affichage de la valeur propre et du vecteur correspondant.
void VeurPropre::Affiche () const
{ // affichage
cout << "\n valeur propre : "<< val<<" et le vecteur propre :";
pv->Affiche();
cout << endl;
};
// surcharge de l'operateur de lecture
// les informations sont le type puis la taille puis les datas
istream & operator >> (istream & entree, VeurPropre & vp)
{ // vérification du type
string type;
entree >> type;
if (type != "VeurPropre")
{Sortie (1);
return entree;
}
// lecture de la valeur
entree >> vp.val;
// puis du vecteur
entree >> *(vp.pv);
return entree;
};
// surcharge de l'operateur d'ecriture non formatée
// les informations sont le type puis les datas séparées par
// un espace
ostream & operator << ( ostream & sort,const VeurPropre & vp)
{ // tout d'abord un indicateur donnant le type pour la valeur
sort << "VeurPropre " << vp.val << " ";
// puis le vecteur
sort << *(vp.pv);
return sort;
};