KstBaseCurvePtr KstCurveHint::makeCurve(const QString& tag, const QColor& color) const {
  KstVectorPtr x = xVector();
  KstVectorPtr y = yVector();
  if (!x || !y) {
    kstdDebug() << "Couldn't find either " << _xVectorName << " or " << _yVectorName << endl;
    return 0L;
  }

  return new KstVCurve(tag, x, y, 0L, 0L, 0L, 0L, color);
}
Exemplo n.º 2
0
void Curve::point(int i, double &x, double &y) const {
  VectorPtr xv = xVector();
  if (xv) {
    x = xv->interpolate(i, NS);
  }
  VectorPtr yv = yVector();
  if (yv) {
    y = yv->interpolate(i, NS);
  }
}
Exemplo n.º 3
0
KstBaseCurvePtr KstCurveHint::makeCurve(const QString& tag, const QColor& color) const {
  KstVectorPtr x = xVector();
  KstVectorPtr y = yVector();

  if (!x || !y) {
    return KstBaseCurvePtr();
  }

  return KstBaseCurvePtr(new KstVCurve(tag, x, y, KstVectorPtr(), KstVectorPtr(), KstVectorPtr(), KstVectorPtr(), color));
}
Exemplo n.º 4
0
void Curve::getEYMinusPoint(int i, double &x, double &y, double &ey) {
  VectorPtr xv = xVector();
  if (xv) {
    x = xv->interpolate(i, NS);
  }
  VectorPtr yv = yVector();
  if (yv) {
    y = yv->interpolate(i, NS);
  }
  VectorPtr eyv = yMinusErrorVector();
  if (eyv) {
    ey = eyv->interpolate(i, NS);
  }
}
Exemplo n.º 5
0
void Curve::getEXMinusPoint(int i, double &x, double &y, double &ex) {
  VectorPtr xv = xVector();
  if (xv) {
    x = xv->interpolate(i, NS);
  }
  VectorPtr yv = yVector();
  if (yv) {
    y = yv->interpolate(i, NS);
  }
  VectorPtr exmv = xMinusErrorVector();
  if (exmv) {
    ex = exmv->interpolate(i, NS);
  }
}
Exemplo n.º 6
0
void CVecTests::ShouldNormalizeItself()
{
    CVec xVector(100,0,0);
    xVector.normalize();
    QVERIFY2(xVector.x() == 1.0, "X component should be normalize to 1.0");

    CVec yVector(0,100,0);
    yVector.normalize();
    QVERIFY2(yVector.y() == 1.0, "Y component should be normalize to 1.0");

    CVec zVector(0,0,100);
    zVector.normalize();
    QVERIFY2(zVector.z() == 1.0, "Z component should be normalize to 1.0");
}
Exemplo n.º 7
0
void Curve::getEYPoints(int i, double &x, double &y, double &eyminus, double &eyplus) {
  VectorPtr xv = xVector();
  if (xv) {
    x = xv->interpolate(i, NS);
  }
  VectorPtr yv = yVector();
  if (yv) {
    y = yv->interpolate(i, NS);
  }
  VectorPtr eyv = yErrorVector();
  if (eyv) {
    eyplus = eyv->interpolate(i, NS);
  }
  VectorPtr eymv = yMinusErrorVector();
  if (eymv) {
    eyminus = eymv->interpolate(i, NS);
  }
}
Exemplo n.º 8
0
RelationPtr Curve::makeDuplicate(QMap<RelationPtr, RelationPtr> &duplicatedRelations) {
  CurvePtr curve = store()->createObject<Curve>();

  if (descriptiveNameIsManual()) {
    curve->setDescriptiveName(descriptiveName());
  }
  curve->setXVector(xVector());
  curve->setYVector(yVector());
  if (hasXError()) {
    curve->setXError(xErrorVector());
  }
  if (hasYError()) {
    curve->setYError(yErrorVector());
  }
  if (hasXMinusError()) {
    curve->setXMinusError(xMinusErrorVector());
  }
  if (hasYMinusError()) {
    curve->setYMinusError(yMinusErrorVector());
  }

  curve->setColor(Color);
  curve->setHasPoints(HasPoints);
  curve->setHasLines(HasLines);
  curve->setHasBars(HasBars);
  curve->setLineWidth(LineWidth);
  curve->setLineStyle(LineStyle);
  curve->setPointType(PointDensity);
  curve->setPointDensity(PointDensity);
  curve->setBarStyle(BarStyle);

  curve->writeLock();
  curve->registerChange();
  curve->unlock();

  duplicatedRelations.insert(this, RelationPtr(curve));
  return RelationPtr(curve);
}
void OpenSMOKE_SensitivityAnalysis_Fast_Flame1D::BuildJAlfaMatrix(BzzVector &T, BzzVector &rho, BzzVector &Cp, vector<string> list_of_names,
																  const double P_Pascal, BzzMatrix &X)
{
	int S_NC = list_of_names.size();
	int S_NV = NV-NC+S_NC;
	int S_NE = S_NV*N;
	ChangeDimensions(S_NE, NP, &S_S);
	BzzVector xVector(NC);
	BzzVector cVector(NC);
	BzzVector RVector(NC);

	for(int n=1;n<=N_BLOCKS+1;n++)
	{
		int iStart;
		int iEnd;
		if (n<N_BLOCKS+1)
		{
			cout << "Internal block..." << endl;
			iStart	= NP_BLOCK*(n-1)+1;
			iEnd	= NP_BLOCK*n;
		}
		else
		{
			cout << "Last block..." << endl;
			iStart	= NP_BLOCK*(n-1)+1;
			iEnd	= NP;
			ChangeDimensions(NE, NP_RESIDUAL, &JAlfa);
			ChangeDimensions(NE, NP_RESIDUAL, &S);
		}

		cout << "Sensitivity Block #" << n << "/" << N_BLOCKS+1 << endl;
		
		JAlfa=0;
		for(int iPoint=1;iPoint<=N;iPoint++)
		{
			int index = (iPoint-1)*NV;

			JAlfaPoint = 0.;
			
			if (iPoint == 1 || iPoint == N)
			{
			}
			else
			{

				double cTot = P_Pascal  / (Constants::R_J_kmol*T[iPoint]);
				X.GetRow(iPoint,&xVector);
				cVector = cTot*xVector;

				mix->ComputeKineticParameters(T[iPoint], log(T[iPoint]), 1./T[iPoint], P_Pascal);
				mix->ComputeFromConcentrations(T[iPoint], cVector, cTot, &RVector);

				if (kindOfParameter == FREQUENCY_FACTOR)						mix->GiveMe_Jalfa_A(JAlfaPoint, nu, T[iPoint], indexSpecies, indexTemperature, parameters);
				else if (kindOfParameter == FREQUENCY_FACTOR_AND_TRANSPORT_PROPERTIES)	mix->GiveMe_Jalfa_A(JAlfaPoint, nu, T[iPoint], indexSpecies, indexTemperature, parameters);
				else ErrorMessage("Wrong Sensitivity Parameter");
				//if (kindOfParameter == BETA)				mix->GiveMe_Jalfa_Beta(JAlfaPoint, nu, T[iPoint], indexSpecies, indexTemperature, parameters);
				//if (kindOfParameter == ACTIVATION_ENERGY)	mix->GiveMe_Jalfa_Eatt(JAlfaPoint, nu, T[iPoint], indexSpecies, indexTemperature, parameters);

				for(int k=1;k<=NP;k++)
					if (parameters[k] <= 0.)	ErrorMessage("Parameters must be larger than zero!");
			}

			// Temperature equations
			if (Cp[1]<0) // this means no energy equation
			{
				for(int j=iStart;j<=iEnd;j++)
					JAlfa[index+indexTemperature][j-iStart+1] = 0;
			}
			else
			{
				for(int j=iStart;j<=iEnd;j++)
					JAlfa[index+indexTemperature][j-iStart+1] = JAlfaPoint[indexTemperature][j]/(rho[iPoint]*Cp[iPoint]);
			}

			// Species equations
			for(int i=1;i<=NC;i++)
				for(int j=iStart;j<=iEnd;j++)
					JAlfa[index+indexSpecies+i-1][j-iStart+1] = JAlfaPoint[indexSpecies+i-1][j]/rho[iPoint];
		}

		JAlfa *= -1.;
		Solve(AFactorized, JAlfa, &S);

		for(int k=iStart;k<=iEnd;k++)
		{
			int j;

			// First Rows 
			for(j=1;j<=indexSpecies-1;j++)
				for(int i=1;i<=N;i++)
					S_S[(i-1)*S_NV+j][k] = S[(i-1)*NV+j][k-iStart+1];

			// Species Rows
			for(j=1;j<=S_NC;j++)
			{
				int index = mix->recognize_species(list_of_names[j-1]);
				for(int i=1;i<=N;i++)
					S_S[(i-1)*S_NV+(j+indexSpecies-1)][k] = S[(i-1)*NV+(index+indexSpecies-1)][k-iStart+1];
			}
		}
	}
}
/*
Return: 
	0: success
	1: fail
*/
int PivotCalibration::GetPivotPointPosition(double* pivotPoint_Marker, double* pivotPoint_Reference)
{
  std::vector<vnl_vector<double> > aMatrix; 
  std::vector<double> bVector;  
  vnl_vector<double> xVector(6,0); // result vector

  vnl_vector<double> aMatrixRow(6);
  for (std::list< vtkMatrix4x4* >::iterator markerToReferenceTransformIt=this->MarkerToReferenceTransformMatrixArray.begin();
    markerToReferenceTransformIt!=this->MarkerToReferenceTransformMatrixArray.end(); ++markerToReferenceTransformIt)
  {    
    for (int i=0; i<3; i++)
    {
      aMatrixRow(0)=(*markerToReferenceTransformIt)->Element[i][0];
      aMatrixRow(1)=(*markerToReferenceTransformIt)->Element[i][1];
      aMatrixRow(2)=(*markerToReferenceTransformIt)->Element[i][2];
      aMatrixRow(3)= (i==0?-1:0);
      aMatrixRow(4)= (i==1?-1:0);
      aMatrixRow(5)= (i==2?-1:0);
      aMatrix.push_back(aMatrixRow);
    }
    bVector.push_back(-(*markerToReferenceTransformIt)->Element[0][3]);
    bVector.push_back(-(*markerToReferenceTransformIt)->Element[1][3]);
    bVector.push_back(-(*markerToReferenceTransformIt)->Element[2][3]);
  }

  double mean = 0;
  double stdev = 0;
  vnl_vector<unsigned int> notOutliersIndices;
  notOutliersIndices.clear();
  notOutliersIndices.set_size(bVector.size());
  for ( unsigned int i = 0; i < bVector.size(); ++i )
  {
    notOutliersIndices.put(i,i);
  }
  if ( LSQRMinimize(aMatrix, bVector, xVector, &mean, &stdev, &notOutliersIndices) != 0 )
  {
    std::cout<<"vtkPivotCalibrationAlgo failed: LSQRMinimize error"<<std::endl; 
    return 1;
  }

  // Note: Outliers are detected and rejected for each row (each coordinate axis). Although most frequently
  // an outlier sample's every component is an outlier, it may be possible that only certain components of an
  // outlier sample are removed, which may be desirable for some cases (e.g., when the point is an outlier because
  // temporarily it was flipped around one axis) and not desirable for others (when the point is completely randomly
  // corrupted), but there would be no measurable difference anyway if the only a few percent of the points are
  // outliers.

  this->OutlierIndices.clear();
  unsigned int processFromRowIndex=0;
  for (int i=0; i<notOutliersIndices.size(); i++)
  {
    unsigned int nextNotOutlierRowIndex=notOutliersIndices[i];
    if (nextNotOutlierRowIndex>processFromRowIndex)
    {
      // samples were missed, so they are outliers
      for (unsigned int outlierRowIndex=processFromRowIndex; outlierRowIndex<nextNotOutlierRowIndex; outlierRowIndex++)
      {
        int sampleIndex=outlierRowIndex/3;  // 3 rows are generated per sample
        this->OutlierIndices.insert(sampleIndex);
      }
    }
    processFromRowIndex=nextNotOutlierRowIndex+1;
  }

  pivotPoint_Marker[0]=xVector[0];
  pivotPoint_Marker[1]=xVector[1];
  pivotPoint_Marker[2]=xVector[2];

  pivotPoint_Reference[0]=xVector[3];
  pivotPoint_Reference[1]=xVector[4];
  pivotPoint_Reference[2]=xVector[5];

  return 0;
}
Exemplo n.º 11
0
QString Curve::propertyString() const {
  return i18n("%1 vs %2").arg(yVector()->Name()).arg(xVector()->Name());
}