コード例 #1
0
ファイル: CAR_DKW_o.cpp プロジェクト: parb220/DKW
bool CAR_DKW_o::SetParameters_InitializeABOmega()
{
	if (!CAR_DKW::SetParameters_InitializeABOmega())
		return false; 

	TDenseMatrix lambda1 = SIGMA_inverse * SIGMAlambda1;
        TDenseVector KAPPAtheta = KAPPA * theta;
        TDenseVector theta_Q;

	aI_Q.Zeros(dataP->MATgrid_options.Dimension());
        bI_Q.Zeros(dataP->MATgrid_options.Dimension(), Nfac);
        
        for (int i=0; i<dataP->MATgrid_options.Dimension(); i++)
        {
                double MAT = dataP->MATgrid_options(i);
                TDenseVector temp_ay;
                TDenseMatrix temp_by;
                if (!YieldFacLoad(temp_ay, temp_by, KAPPA_rn, Inv_KAPPA_rn, Inv_Kron_KAPPA_rn, SIGMA, KAPPAtheta, rho0, rho1, lambda0,TDenseVector(1,MAT)))
                        return false;
                TDenseVector temp_by_vector = temp_by.RowVector(0); // -MAT * temp_by.RowVector(0);

                theta_Q = Multiply(Inv_KAPPA_rn, KAPPAtheta-SIGMA*lambda0+MultiplyTranspose(SIGMA,SIGMA)*temp_by_vector);

                double rho0_Q = rho0_pi - InnerProduct(lambda0, sigq)+InnerProduct(sigq, TransposeMultiply(SIGMA,temp_by_vector));
                TDenseVector rho1_Q = rho1_pi - TransposeMultiply(lambda1, sigq);

                double temp_aI_Q;
                TDenseVector temp_bI_Q;
                InfExpFacLoad(temp_aI_Q, temp_bI_Q, KAPPA_rn, Inv_KAPPA_rn, Inv_Kron_KAPPA_rn, SIGMA, theta_Q, sigq, sigqx, rho0_Q, rho1_Q, MAT);

                aI_Q(i) = temp_aI_Q;
                bI_Q.InsertRowMatrix(i, 0, temp_bI_Q);
        }
	return true; 
}
コード例 #2
0
ファイル: MatrixRmn.cpp プロジェクト: hellojas/bullet3
void MatrixRmn::ComputeInverse( MatrixRmn& R) const
{
    assert ( this->NumRows==this->NumCols );
    MatrixRmn U(this->NumRows, this->NumCols);
    VectorRn w(this->NumRows);
    MatrixRmn V(this->NumRows, this->NumCols);
    
    this->ComputeSVD(U, w, V);
    
    assert(this->DebugCheckSVD(U, w , V));
    
    double PseudoInverseThresholdFactor = 0.01;
    double pseudoInverseThreshold = PseudoInverseThresholdFactor*w.MaxAbs();
    
    MatrixRmn VD(this->NumRows, this->NumCols);
    MatrixRmn D(this->NumRows, this->NumCols);
    D.SetZero();
    long diagLength = w.GetLength();
    double* wPtr = w.GetPtr();
    for ( long i = 0; i < diagLength; ++i ) {
        double alpha = *(wPtr++);
        if ( fabs(alpha)>pseudoInverseThreshold ) {
            D.Set(i, i, 1.0/alpha);
        }
    }
    
    Multiply(V,D,VD);
    MultiplyTranspose(VD,U,R);
}
コード例 #3
0
ファイル: MultiplyAdjoint.cpp プロジェクト: arbenson/HIFDE3D
void MultiplyAdjoint
( int maxRank, Real alpha,
  const Dense<Real>& A,
  const Dense<Real>& B,
        LowRank<Real>& C )
{
#ifndef RELEASE
    CallStackEntry entry("hmat_tools::MultiplyAdjoint (F := D D^H)");
#endif
    MultiplyTranspose( maxRank, alpha, A, B, C );
}