void PairRegressionAnalyzer::printResults(QTableWidget * table) {
    table->setColumnCount(results.count());
    table->setRowCount(results[0].count());

    table->setHorizontalHeaderItem(0,new QTableWidgetItem("x"));
    table->setHorizontalHeaderItem(1,new QTableWidgetItem("y"));
    table->setHorizontalHeaderItem(2,new QTableWidgetItem("y''"));

    for(int col=0;col<results.count();col++)
        for(int row=0;row<results[col].count();row++)
            table->setItem(row,col,new QTableWidgetItem(QString::number(results[col][row])));

    Point3D coords;
    coords.x = 5.0f;
    coords.y = 5.0f;
    coords.z = 5.0f;
    Point3D coordsScale;
    coordsScale.x = 5.0/maxElement(results[0]);
    coordsScale.y = 5.0/maxElement(results[1]);
    coordsScale.z = 1;
    QList<QString> coordLables;

    QWidget * tab1 = AdditionalWidgets.at(0);
    tab1->setObjectName("График");
    PairRegressionAnalyzerGraphic * g1 = new PairRegressionAnalyzerGraphic(tab1);
    coordLables.append("");
    coordLables.append("");
    g1->SetCoordsData(coords, coordLables,Figure3D::black, Figure3D::darkGreen, &coordsScale);
    g1->SetPoints(getYPoints());
    g1->SetLinePoints(getY2Points());
    g1->SetErrorText("Качество оценивания: " + QString::number(R));
    g1->SetEquation("y'' = " + QString::number(A) + " + " + QString::number(B) + "x");
    tab1->setLayout(new QGridLayout());
    tab1->layout()->addWidget(g1);
}
QList<Point3D> PairRegressionAnalyzer::getY2Points() {
    double xScale = 5.0/maxElement(results[0]);
    double yScale = 5.0/maxElement(results[1]);
    QList<Point3D> result;
    for (int i=0;i<results[0].size();i++) {
        Point3D p;
        p.x = results[0][i]*xScale;
        p.y = results[2][i]*yScale;
        result.append(p);
    }
    return result;
}
QList<Point3DEx> PairRegressionAnalyzer::getYPoints() {
    double xScale = 5.0/maxElement(results[0]);
    double yScale = 5.0/maxElement(results[1]);
    QList<Point3DEx> result;
    for (int i=0;i<results[0].size(); i++) {
        Point3DEx p;
        p.x = results[0][i]*xScale;
        p.y = results[1][i]*yScale;
        p.label = QString::number(i+1);
        p.color = Figure3D::red;
        result.append(p);
    }
    return result;
}
Example #4
0
void setHilbertParams(Parameters &ether, Aux &aux,Geometry const &geometry)
{
	int n=geometry.volume(), d=geometry.dim();
	int i;
	
	ether.typeofmodel="MODEL_KONDO_DMS_ZINCBLENDE";
	ether.hilbertSize=4*n;
	ether.nonzero= ether.numberOfOrbitals*(1+ether.numberOfOrbitals*geometry.z(0)) * n+
		ether.numberOfOrbitals*n*0.5*(ether.numberOfOrbitals-1);
	if (!(geometry.latticeName()=="zincblende")) {
		cerr<<"I was expecting zincblende geometry but instead you input "<<geometry.latticeName()<<endl;
		cerr<<"At this point: "<<__FILE__<<" "<<__LINE__<<endl;
		exit(1);
	}
	
	cerr<<ether.bandHoppings.size()<<endl;
	vectorPrint(ether.bandHoppings,"hoppings=",cerr);
	ether.energy1= -3-maxElement(ether.J);
	ether.energy2= -ether.energy1;
	aux.varTpem_a = 0.5*(ether.energy2-ether.energy1);
	aux.varTpem_b = 0.5*(ether.energy2+ether.energy1);
	ether.classFieldList.push_back(0);
	
	
}
Example #5
0
void setHilbertParams(Parameters &ether, Aux &aux,Geometry const &geometry)
{
    int n=geometry.volume(), d=geometry.dim();

    ether.typeofmodel="MODEL_KONDO_INF_TWOBANDS";
    ether.hilbertSize=2*n;
    ether.nonzero= 4 * (2*d + 1) * n;
    if (!ether.isSet("spectrumbounds")) {
        ether.energy1= -2*d*maxElement(ether.bandHoppings)-maxElement(ether.potential);
        ether.energy2= -ether.energy1;
    }
    aux.varTpem_a = 1; //0.5*(ether.energy2-ether.energy1);
    aux.varTpem_b = 0; //0.5*(ether.energy2+ether.energy1);
    ether.classFieldList.push_back(0);
    ether.classFieldList.push_back(1);


}
Example #6
0
  void decompose( const Matnnt<3,float> &mat, Quatt<float> &orientation, Vecnt<3,float> &scaling
                , Quatt<float> &scaleOrientation )
  {
#if 0

    //NVSG_PRIVATE_ASSERT( std::numeric_limits<float>::epsilon() < abs( determinant( mat ) ) );

    Matnnt<3,float> rot, sca;
    float det = _polarDecomposition( mat, rot, sca );
#if !defined(NDEBUG)
    {
      //NVSG_PRIVATE_ASSERT( isRotation( rot, 3*std::numeric_limits<float>::epsilon() ) );
      Matnnt<3,float> diff = mat - (float)sign(det) * sca * rot;
      float eps = std::max( 1.0f, maxElement( sca ) ) * std::numeric_limits<float>::epsilon();
      //NVSG_PRIVATE_ASSERT( isNull( diff, 4*eps ) );
    }
#endif

    orientation = Quatt<float>(rot);

    //  get the scaling out of sca
    Matnnt<3,float> so;
    scaling = (float)sign(det) * _spectralDecomposition( sca, so );
#if !defined( NDEBUG )
    {
      //NVSG_PRIVATE_ASSERT( isRotation( so, 3*std::numeric_limits<float>::epsilon() ) );
      Matnnt<3,float> k( scaling[0], 0, 0,  0, scaling[1], 0,  0, 0, scaling[2] );
      Matnnt<3,float> diff = sca - ~so * k * so;
      float eps = std::max( 1.0f, maxElement( scaling ) ) * std::numeric_limits<float>::epsilon();
      //NVSG_PRIVATE_ASSERT( isNull( diff, 4*eps ) );
    }
#endif

    scaleOrientation = Quatt<float>( so );

#if !defined( NDEBUG )
    {
      Matnnt<3,float> ms( scaling[0], 0, 0, 0, scaling[1], 0, 0, 0, scaling[2] );
      Matnnt<3,float> mso( so );
      Matnnt<3,float> diff = mat - ~mso * ms * mso * rot;
      float eps = std::max( 1.0f, maxElement( scaling ) ) * std::numeric_limits<float>::epsilon();
      //NVSG_PRIVATE_ASSERT( isNull( diff, 5*eps ) );
    }
#endif

#else



    Matnnt<3,double> rot, sca;
    double det = _polarDecomposition( Matnnt<3,double>(mat), rot, sca );
#if !defined(NDEBUG)
    {
      //NVSG_PRIVATE_ASSERT( isRotation<double>( rot, std::numeric_limits<float>::epsilon() ) );
      Matnnt<3,double> diff = Matnnt<3,double>(mat) - sca * rot;
      double eps = std::max( 1.0, maxElement( sca ) ) * std::numeric_limits<float>::epsilon();
      //NVSG_PRIVATE_ASSERT( isNull( diff, eps ) );
    }
#endif

    orientation = Quatt<float>(Quatt<double>(rot));

    //  get the scaling out of sca
    Matnnt<3,double> so;

	if( fabs(det) > FLT_EPSILON )
	{
	    scaling = (double)sign(det) * _spectralDecomposition( sca, so );
	    scaleOrientation = Quatt<float>(Quatt<double>( so ));
	}
	else
	{
		scaling = Vec3f(0.0f, 0.0f, 0.0f);
		scaleOrientation = Quatf( Vec3f(0.0f, 0.0f, 1.0f), 0.0f );
	}

#endif
  }
void LinearRegressionAnalyzer::DoAnalyze() {
    BaseAnalyzer::DoAnalyze();

    QList<double> yList = matrix[0];
    QList<QList<double> > xMatrix;
    for (int i=1;i<matrix.size();i++) {
        xMatrix.append(matrix[i]);
    }

    QList<QList<double> > xNMatrix;
    for (int i=0;i<xMatrix.size();i++) {
        QList<double> xNiMatrix;
        double avg = average(xMatrix[i]);
        QList<double> razn;
        for (int j=0;j<xMatrix[i].size();j++) {
            razn.append(fabs(xMatrix[i][j] - avg));
        }
        double R = maxElement(razn);
        for (int j=0;j<xMatrix[i].size();j++)
            xNiMatrix.append((xMatrix[i][j] - avg)/R);
        xNMatrix.append(xNiMatrix);
    }

    QList<double> bMatrix;
    double temp = 0.0;
    for (int i=0;i<yList.size();i++)
        temp += yList[i];
    bMatrix.append(temp);
    for (int i=0;i<xNMatrix.size();i++) {
        temp = 0.0;
        for (int j=0;j<xNMatrix[i].size();j++) {
            temp += yList[j] * xNMatrix[i][j];
        }
        bMatrix.append(temp);
    }

    QList<QList<double> > aMatrix;
    QList<double> firstRow;
    firstRow.append(yList.size());
    for (int i=0;i<xNMatrix.size();i++)
        firstRow.append(sumElements(xNMatrix[i]));
    aMatrix.append(firstRow);
    for (int row=0;row<xNMatrix.size();row++) {
        QList<double> tempRow;
        for (int col=0;col<bMatrix.size();col++) {
            if (col<=row) {
                tempRow.append(0.0);
            }
            else {
                if (col>0) {
                    tempRow.append(sumListsElements(xNMatrix[col-1], xNMatrix[row]));
                }
            }
        }
        aMatrix.append(tempRow);
    }

    for (int row = 0;row<aMatrix.size();row++) {
        for (int col = 0; col < aMatrix[row].size();col++) {
            if (row <= col)
                continue;
            aMatrix[row][col] = aMatrix[col][row];
        }
    }

    results = Gauss(aMatrix, bMatrix);


    QList<double> y2List;
    for (int i=0;i<xNMatrix[0].size();i++) {
        temp = 0.0;
        for (int j= 0;j<results.size();j++) {
            if (j<results.size()-1)
                temp += results[j] * xNMatrix[j][i];
            else
                temp += results[j];
        }
        y2List.append(temp);
    }

    double y2Avg = average(y2List);
    double yAvg = average(yList);

    double RUp = 0.0, RDown = 0.0;
    for (int i=0;i<yList.size();i++) {
        RUp += (y2List[i]-y2Avg)*(y2List[i]-y2Avg);
        RDown += (yList[i] - yAvg)*(yList[i] - yAvg);
    }

    R2 = RUp/RDown;
}