本文整理汇总了C++中MyMatrix类的典型用法代码示例。如果您正苦于以下问题:C++ MyMatrix类的具体用法?C++ MyMatrix怎么用?C++ MyMatrix使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MyMatrix类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertToRotationMatrix
MyMatrix MyQuat::convertToRotationMatrix(void) const
{
MyMatrix result;
GLfloat rotMatrix[16];
float xx = this->w * this->w;
float xy = this->w * this->v.x;
float xz = this->w * this->v.y;
float xw = this->w * this->v.z;
float yy = this->v.x * this->v.x;
float yz = this->v.x * this->v.y;
float yw = this->v.x * this->v.z;
float zz = this->v.y * this->v.y;
float zw = this->v.y * this->v.z;
rotMatrix[0] = 1 - 2 * (yy + zz);
rotMatrix[1] = 2 * (xy - zw);
rotMatrix[2] = 2 * (xz + yw);
rotMatrix[4] = 2 * (xy + zw);
rotMatrix[5] = 1 - 2 * (xx + zz);
rotMatrix[6] = 2 * (yz - xw);
rotMatrix[8] = 2 * (xz - yw);
rotMatrix[9] = 2 * (yz + xw);
rotMatrix[10] = 1 - 2 * (xx + yy);
rotMatrix[3] = rotMatrix[7] = rotMatrix[11] = rotMatrix[12] = rotMatrix[13] = rotMatrix[14] = 0;
rotMatrix[15] = 1;
result.setMyMatrix(rotMatrix);
return result;
}
示例2: sqrt
void * Chi2Lib::computeDifferenceThread( void* ptr){
PartitionDiff *part = (PartitionDiff*) ptr;
MyMatrix<double> *img = part->img;
MyMatrix<double> *grid_x = part->grid_x;
MyMatrix<double> *grid_y = part->grid_y;
double d = part->d;
double w = part->w;
MyMatrix<double> *diffout = part->diffout;
MyLogger::log()->debug("[Chi2Lib][computeDifferenceThread] Computing Chi2 Difference");
double chi2err = 0.0;
for(unsigned int x=part->x1; x < part->x2; ++x){
for(unsigned int y=part->y1; y < part->y2; ++y){
double x2y2 = sqrt(1.0*grid_x->getValue(x,y)*grid_x->getValue(x,y) + 1.0*grid_y->getValue(x,y)*grid_y->getValue(x,y));
double temp = ((1.0-tanh( (x2y2-d/2.0)/w )) - 2.0*img->getValue(x,y))/2.0;
diffout->at(x,y) = temp;
chi2err += temp*temp;
}
}
MyLogger::log()->debug("[Chi2Lib][computeDifferenceThread] Chi2 Error: %f", chi2err);
part->err = chi2err;
return 0;
}
示例3: MyAssert
void MenuSlider::Draw(MyMatrix* pMatProj, MyMatrix* pMatView)
{
float centerx = m_PosX;
float top = m_PosY;
// TODO: take more justifications and vertical/horizontal into account for top and left.
// should ideally be done once instead of every frame.
//if( m_Justification & Justify_Left )
//{
// centerx += m_BarThickness/2;
//}
float emptypos = (m_PosY - m_VisualRange);
MyAssert( m_pSprite );
//m_pSprite = g_pGame->m_pResources->m_pSprites[SL_WhiteSquareResizable];
if( m_pSprite )
{
BufferManager* pBufferManager = m_pGameCore->GetManagers()->GetBufferManager();
m_pSprite->Create( pBufferManager, "MenuSlider", m_BarThickness, m_VisualRange, 0, 1, 0, 1, Justify_CenterX|Justify_Top );
MyMatrix world;
world.SetIdentity();
world.SetTranslation( centerx, top, 0 );
//FIX m_pSprite->SetTint( m_Colors[MSCT_BarColor] );
m_pSprite->Draw( pMatProj, pMatView, &world ); //&g_pGame->m_OrthoMatrix );
m_pSprite->Create( pBufferManager, "MenuSlider", m_HandleWidth, m_HandleHeight, 0, 1, 0, 1, Justify_CenterX|Justify_Top );
world.SetTranslation( centerx, emptypos + m_ValuePerc*m_VisualRange, 0 );
//FIX m_pSprite->SetTint( m_Colors[MSCT_HandleColor] );
m_pSprite->Draw( pMatProj, pMatView, &world ); //&g_pGame->m_OrthoMatrix );
}
}
示例4: Cells
xlw::CellMatrix::CellMatrix(const MyMatrix& data): Cells(data.size1()),
Rows(data.size1()), Columns(data.size2())
{
for (size_t i=0; i < data.size1(); ++i)
for (size_t j=0; j < data.size2(); ++j)
Cells[i].push_back(CellValue(Element(data,i,j)));
}
示例5:
MyMatrix MyMatrix::operator+(const MyMatrix& A)
{
MyMatrix result;
result.setN(fN);
result.setM(fM);
result.fMatrix = fMatrix+A.fMatrix;
return result;
}
示例6: BSDeltaWithParamsFD
double BSDeltaWithParamsFD(const MyMatrix& parametersMatrix, double epsilon) {
if (parametersMatrix.columns() != 6 && parametersMatrix.rows() != 1 ) {
throw("Input matrix should be 1 x 5");}
double Spot = parametersMatrix(0,0);
double Strike = parametersMatrix(0,1);
double r = parametersMatrix(0,2);
double d = parametersMatrix(0,3);
double vol = parametersMatrix(0,4);
double expiry = parametersMatrix(0,5);
return BlackScholesDeltaFD(Spot, Strike,r,d,vol,expiry, epsilon);
}
示例7: BSZeroCouponBondWithParams
double BSZeroCouponBondWithParams(const MyMatrix& parametersMatrix){
if (parametersMatrix.columns() != 6 && parametersMatrix.rows() != 1 ) {
throw("Input matrix should be 1 x 5");}
double Spot = parametersMatrix(0,0);
double Strike = parametersMatrix(0,1);
double r = parametersMatrix(0,2);
double d = parametersMatrix(0,3);
double vol = parametersMatrix(0,4);
double expiry = parametersMatrix(0,5);
return BlackScholesZeroCouponBond(Spot, Strike,r,d,vol,expiry);
}
示例8: defaultCellMatrixImpl
CellMatrix::CellMatrix(const MyMatrix& data):pimpl(new defaultCellMatrixImpl(data.rows(),data.columns()))
{
for(size_t i(0); i < data.rows(); ++i)
{
for(size_t j(0); j < data.columns(); ++j)
{
(*pimpl)(i,j) = data(i,j);
}
}
}
示例9: sinf
void MyMatrix::RotateZ(float angle)
{
float sinAngle, cosAngle;
sinAngle = sinf ( angle * PI / 180.0f );
cosAngle = cosf ( angle * PI / 180.0f );
MyMatrix temp;
temp.LoadIndentity();
temp.m[0][0] = temp.m[1][1] = cosAngle;
temp.m[0][1] = sinAngle;
temp.m[1][0] = -sinAngle;
MatrixMultiply(&temp,this);
}
示例10:
void operator/(const MyMatrix &b){ // transpose
for(int i = 0; i < _dim; i++){
for(int j = 0; j < _dim; j++){
vecvec[i][j] = b.get(j,i);
}
}
}
示例11: BSGreeksFD
CellMatrix //
BSGreeksFD(const MyMatrix& parametersMatrix,double epsilon) {
if (parametersMatrix.columns() != 6 && parametersMatrix.rows() != 1 ) {
throw("Input matrix should be 1 x 5");}
double Spot = parametersMatrix(0,0);
double Strike = parametersMatrix(0,1);
double r = parametersMatrix(0,2);
double d = parametersMatrix(0,3);
double vol = parametersMatrix(0,4);
double expiry = parametersMatrix(0,5);
CellMatrix resultMatrix(1,5);
resultMatrix(0,0) = BlackScholesDeltaFD(Spot,Strike,r,d,vol,expiry,epsilon);
resultMatrix(0,1) = BlackScholesGammaFD(Spot,Strike,r,d,vol,expiry,epsilon);
resultMatrix(0,2) = BlackScholesVegaFD(Spot,Strike,r,d,vol,expiry,epsilon);
resultMatrix(0,3) = BlackScholesRhoFD(Spot,Strike,r,d,vol,expiry,epsilon);
resultMatrix(0,4) = BlackScholesThetaFD(Spot,Strike,r,d,vol,expiry,epsilon);
return resultMatrix;
}
示例12: BSGreeks
CellMatrix // returns delta, gamma, vega, rho, theta
BSGreeks(const MyMatrix& parametersMatrix) {
if (parametersMatrix.columns() != 6 && parametersMatrix.rows() != 1 ) {
throw("Input matrix should be 1 x 5");}
double Spot = parametersMatrix(0,0);
double Strike = parametersMatrix(0,1);
double r = parametersMatrix(0,2);
double d = parametersMatrix(0,3);
double vol = parametersMatrix(0,4);
double expiry = parametersMatrix(0,5);
CellMatrix resultMatrix(1,5);
resultMatrix(0,0) = BlackScholesDelta(Spot,Strike,r,d,vol,expiry);
resultMatrix(0,1) = BlackScholesGamma(Spot,Strike,r,d,vol,expiry);
resultMatrix(0,2) = BlackScholesVega(Spot,Strike,r,d,vol,expiry);
resultMatrix(0,3) = BlackScholesRho(Spot,Strike,r,d,vol,expiry);
resultMatrix(0,4) = BlackScholesTheta(Spot,Strike,r,d,vol,expiry);
return resultMatrix;
}
示例13: SetViewTransformation
/**********************************************************
*
* SetViewTransformation
*
* parameters IN :
* MyMatrix & viewTransformation
*
*********************************************************/
void ViewPointRec::SetViewTransformation (MyMatrix & viewTransformation) {
viewTransformation.Identity();
viewTransformation[0][0] = -sinTheta;
viewTransformation[0][1] = -cosTheta * cosPhi;
viewTransformation[0][2] = -cosTheta * sinPhi;
viewTransformation[1][0] = cosTheta;
viewTransformation[1][1] = -sinTheta * cosPhi;
viewTransformation[1][2] = -sinTheta * sinPhi;
viewTransformation[2][1] = sinPhi;
viewTransformation[2][2] = -cosPhi;
viewTransformation[3][2] = rho;
}
示例14: MyVector
MyVector operator*(const MyMatrix& lhs ,const MyVector& rhs) {
MyVector y = MyVector(lhs.rows_);
if (lhs.columns_ == rhs.size()) {
for(long long int i = 1; i <= lhs.rows_; i++) {
for(long long int j = 1; j <= lhs.columns_; j++) {
y[i-1] += rhs[j-1] *lhs.at(i,j);
}
}
} else {
cout << "Matrix-Vektor-Multiplikation nicht möglich Dimensionen stimmen nicht überein!" << endl;
}
return y;
}
示例15: MyMatrix
MyMatrix MyMatrix::operator*(const MyMatrix& rhs) {
MyMatrix lhs = *this;
auto n=lhs.rows_;
auto m = lhs.columns_;
auto p = rhs.columns_;
MyMatrix y = MyMatrix(n,p);
if (m == rhs.rows_) {
for(long long int i = 1; i <= n; i++) {
for(long long int j = 1; j <= p; j++) {
y.mval_[(i-1)*(p) + (j-1)]=0;
for(long long int k = 1; k <= m; k++) {
y.mval_[(i-1)*(p) + (j-1)] += lhs.at(i,k)*rhs.at(k,j) ;
}
}
}
}
else {
cout << "Dimensionen stimmen nicht überein!" << endl;
}
return y;
}