22 if(npoints<nincog)
return false;
36 A.
Redim(nincog,nincog);
37 DeltaH.
Redim(npoints,nincog);
38 DeltaHTranspose.
Redim(nincog,npoints);
39 DifSol.
Redim(npoints,1);
43 for(i=0;i<npoints;i++)
47 for(
int i=0;i<npoints;i++) {
56 for(i=0;i<npoints;i++)
60 for(
int i=0;i<npoints;i++) {
75 A = DeltaHTranspose*DeltaH;
77 Coefficients = DeltaHTranspose*DifSol;
79 for (
int i=0; i<Coefficients.
Rows(); i++) {
94 nincog = 2*dim+1+2*(dim-2);
96 if(npoints<nincog)
return false;
110 A.
Redim(nincog,nincog);
111 DeltaH.
Redim(npoints,nincog);
112 DeltaHTranspose.
Redim(nincog,npoints);
113 DifSol.
Redim(npoints,1);
117 for(i=0;i<npoints;i++)
121 for(
int i=0;i<npoints;i++) {
131 for(i=0;i<npoints;i++)
135 for(
int i=0;i<npoints;i++) {
153 A = DeltaHTranspose*DeltaH;
155 Coefficients = DeltaHTranspose*DifSol;
161 temp = Coefficients(1,0)*Coefficients(1,0)/Coefficients(0,0);
162 temp -= (Coefficients(2,0)*Coefficients(2,0));
163 if(Coefficients(0,0) > 0 || (4*Coefficients(3,0)) < temp)
167 temp = Coefficients(1,0)*Coefficients(1,0)/Coefficients(0,0);
168 if(Coefficients(0,0) > 0)
171 for (
int i=0; i<Coefficients.
Rows(); i++) {
182 if(npoints<nincog)
return false;
186 Coefficients.
Redim(nincog,1);
197 A.
Redim(nincog,nincog);
198 DeltaH.
Redim(npoints,nincog);
199 DeltaHTranspose.
Redim(nincog,npoints);
200 DifSol.
Redim(npoints,1);
204 for(i=0;i<npoints;i++)
208 for(
int i=0;i<npoints;i++) {
218 A = DeltaHTranspose*DeltaH;
219 Coefficients = DeltaHTranspose*DifSol;
221 for (
int i=0; i<Coefficients.
Rows(); i++) {
235 for(nr=0;nr<mat.
Rows();nr++) {
236 for(nc=0;nc<mat.
Cols();nc++) {
252 out <<
"\nPrinting axes of the ellipse:\n";
254 for(
int i=0;i<P.
Cols();i++) {
255 out <<
"Vector" << i+1 <<
" = ( ";
256 for(
int j=0;j<P.
Rows();j++) {
284 temp1 = temp/(4*fcoefficients[0]*fcoefficients[0]);
285 if(temp1 < 0. ||
IsZero(temp1))
287 Ratios[0] =
sqrt(temp1);
288 temp1 = (-temp)/(4*fcoefficients[0]);
289 Ratios[1] =
sqrt(temp1);
291 else if(ncoeffs == 6) {
297 if(temp < 0.)
return false;
298 Ratios[2] =
sqrt(temp);
300 temp = -(Ratios[2]*Ratios[2]/fcoefficients[2]);
301 if(temp < 0.)
return false;
302 Ratios[1] =
sqrt(temp);
303 temp = -(Ratios[2]*Ratios[2]/fcoefficients[0]);
304 if(temp < 0.)
return false;
305 Ratios[0] =
sqrt(temp);
307 else if(ncoeffs == 2)
315 if(temp < 0. || Ratios[1] < 0.)
317 Ratios[0] =
sqrt(Ratios[1]);
318 Ratios[1] =
sqrt(temp);
329 out <<
"\nElipse: (x - " << Center[0] <<
")^2/" << Ratios[0]*Ratios[0] <<
" + (y - " << Center[1] <<
")^2/" << Ratios[1]*Ratios[1] <<
" = 1.\n" << std::endl;
334 out <<
"\nElipse: (x - " << Center[0] <<
")^2/" << Ratios[0]*Ratios[0] <<
" + (y - " << Center[1] <<
")^2/" << Ratios[1]*Ratios[1] <<
" = 1.\n" << std::endl;
339 out << fcoefficients[4] <<
"z + " << fcoefficients[5] << std::endl;
340 out <<
"\nElipse: (x - " << Center[0] <<
")^2/" << Ratios[0]*Ratios[0] <<
" + (y - " << Center[1] <<
")^2/" << Ratios[1]*Ratios[1];
341 out <<
" + (z - " << Center[2] <<
")^2/" << Ratios[2]*Ratios[2] <<
" = 1.\n" << std::endl;
360 std::cout <<
"\n\nCoefficients after least square for quadratic equation:";
382 std::cout <<
"\n\nSolution:";
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
bool AdjustingWithEllipse()
bool IsZero(long double a)
Returns if the value a is close Zero as the allowable tolerance.
void AlmostZeroToZero(TPZFMatrix< REAL > &mat)
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
void PrintingAsSimpleEquation(TPZVec< REAL > &Center, TPZVec< REAL > &Ratios, std::ostream &out)
int Zero() override
Makes Zero all the elements.
int64_t size() const
Returns the number of elements of the vector.
void PrintAxes(TPZFMatrix< REAL > &P, std::ostream &out)
#define DebugStop()
Returns a message to user put a breakpoint in.
bool AdjustingWithVerySimpleEllipse()
int64_t Rows() const
Returns number of rows.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
bool AdjustingWithSimpleEllipse()
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
TPZManVector< REAL, 6 > fcoefficients
coefficients determined by the least squares problem
TPZFMatrix< REAL > fPoints
Points which determine the projection.
bool StandardFormatForSimpleEllipse(TPZVec< REAL > &Center, TPZVec< REAL > &Ratios)
void Fill(const T ©, const int64_t from=0, const int64_t numelem=-1)
Will fill the elements of the vector with a copy object.
int64_t Cols() const
Returns number of cols.
int64_t NElements() const
Returns the number of elements of the vector.
REAL fTol
Tolerance to project the coefficients to zero value.
bool LeastSquaresToGetEllipse()
REAL ZeroTolerance()
Returns the tolerance to Zero value. Actually: .
int PutVal(const int64_t row, const int64_t col, const TVar &value) override
Put values without bounds checking This method is faster than "Put" if DEBUG is defined.
const TVar & GetVal(const int64_t row, const int64_t col) const override
Get values without bounds checking This method is faster than "Get" if DEBUG is defined.
void Transpose(TPZMatrix< TVar > *const T) const override
It makes *T the transpose of current matrix.
virtual int SolveDirect(TPZFMatrix< TVar > &F, const DecomposeType dt, std::list< int64_t > &singular)
Solves the linear system using Direct methods.
bool LeastSquaresToGetSimpleEllipse()
bool LeastSquaresToGetVerySimpleEllipse()