本文整理汇总了C++中mat3::transpose方法的典型用法代码示例。如果您正苦于以下问题:C++ mat3::transpose方法的具体用法?C++ mat3::transpose怎么用?C++ mat3::transpose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mat3
的用法示例。
在下文中一共展示了mat3::transpose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// I had to move it here because it depends on AtomicPair class which is defined after LaueSymmetry
vector<AtomicPair> LaueSymmetry::multiply_pairs_by_matrix(vector<AtomicPair> pairs,mat3<double> transformation_matrix) {
vector<AtomicPair>::iterator pair;
for(pair=pairs.begin(); pair!=pairs.end(); pair++)
{
for(int average=0; average<2; average++)
{
pair->r(average)=transformation_matrix*pair->r(average);
pair->U(average)=trusted_mat_to_sym_mat(transformation_matrix*pair->U(average)*transformation_matrix.transpose());
}
}
return pairs;
}
示例2:
vec3 operator*(const vec3 &v, const mat3 &a)
{
return a.transpose() * v;
}
示例3:
vec2 operator * (const vec2& v, mat3& a)
{ return a.transpose() * v; }
示例4: dec
//.........这里部分代码省略.........
case 3:
{
double scale = max( max( max( max(abs(S[p-1]), abs(S[p-2]) ), abs(e[p-2]) ),abs(S[k,k]) ), abs(e[k]) );
double sp = S[p-1] / scale;
double spm1 = S[p-2] / scale;
double epm1 = e[p-2] / scale;
double sk = S[k] / scale;
double ek = e[k] / scale;
double b = ( (spm1+sp)*(spm1-sp) + epm1*epm1 ) / 2.0;
double c = (sp*epm1) * (sp*epm1);
double shift = 0;
if( ( b != 0 ) || ( c != 0 ) )
{
shift = sqrt( b*b+c );
if( b < 0 )
shift = -shift;
shift = c / ( b+shift );
}
double f = (sk+sp)*(sk-sp) + shift;
double g = sk * ek;
// chase zeros
for( j=k; j<p-1; ++j )
{
double t = hypot( f, g );
double cs = f / t;
double sn = g / t;
if( j != k )e[j-1] = t;
f = cs*S[j] + sn*e[j];
e[j] = cs*e[j] - sn*S[j];
g = sn * S[j+1];
S[j+1] = cs * S[j+1];
for( i=0; i<3; ++i )
{
t = cs*Vt[i][j]+ sn*Vt[i][j+1];
Vt[i][j+1] = -sn*Vt[i][j] + cs*Vt[i][j+1];
Vt[i][j]= t;
}
t = hypot( f, g );
cs = f / t;
sn = g / t;
S[j] = t;
f = cs*e[j] + sn*S[j+1];
S[j+1] = -sn*e[j] + cs*S[j+1];
g = sn * e[j+1];
e[j+1] = cs * e[j+1];
for( i = 0; i < 3; ++ i )
{
t = cs*U[i][j] + sn*U[i][j+1] ;
U[i][j+1]= -sn*U[i][j] + cs*U[i][j+1];
U[i][j] = t;
}
}
e[p-2] = f;
iter = iter + 1;
}
break;
// convergence
case 4:
{
if( S[k] <= 0 )
{
S[k] = ( S[k] < 0 ) ? -S[k] : 0;
for( i = 0; i <= pp; ++ i ) Vt[i][k]= -Vt[i][k];
}
/*while( k < pp )
{
if( S[k] >= S[k+1] )break;
double t = S[k];
S[k] = S[k+1];
S[k+1] = t;
if(k < 2 )
for( i = 0; i < 3; ++ i )
swap( Vt[i][k], Vt[i][k+1]);
if( k < 2 )
for( i = 0; i < 3; ++ i )
swap( U[i][k], U[i][k+1] );
k ++;
}*/
iter = 0;
p --;
}
break;
}
}
Vt = Vt.transpose();
}
示例5: PolarDecompose
void PolarDecomposer::PolarDecompose(const mat3& A, mat3& Q, mat3& S, double& det, double tolerance)
{
mat3 At = A.transpose();
mat3 Aadj;
mat3 Ek;
double A_one = norm_one(At);
double A_inf = norm_inf(At);
double Aadj_one, Aadj_inf, E_one, gamma, g1, g2;
do
{
Aadj = mat3(At[1].Cross(At[2]), At[2].Cross(At[0]), At[0].Cross(At[1]));
det = At[0][0] * Aadj[0][0] + At[0][1] * Aadj[0][1] + At[0][2] * Aadj[0][2];
if(det == 0.0)
{
//TODO: handle this case
printf("Warning: zero determinant encountered.\n");
break;
}
Aadj_one = norm_one(Aadj);
Aadj_inf = norm_inf(Aadj);
gamma = sqrt(sqrt((Aadj_one*Aadj_inf)/(A_one*A_inf))/fabs(det));
g1 = gamma * 0.5;
g2 = 0.5/(gamma*det);
for(unsigned int i = 0; i < 3; i++)
for(unsigned int j = 0; j < 3; j++)
{
Ek[i][j] = At[i][j];
At[i][j] = g1 * At[i][j] + g2 * Aadj[i][j];
Ek[i][j] -= At[i][j];
}
E_one = norm_one(Ek);
A_one = norm_one(At);
A_inf = norm_inf(At);
}
while( E_one > A_one * tolerance);
if(fabs(det) < EPSILON)//edit by Xing
Q = mat3::Identity();
else
Q = At.transpose();
//TODO: if S is to be used. uncomment this part
for(unsigned int i = 0; i < 3; i++)
for(unsigned int j = 0; j < 3; j++)
{
S[i][j] = 0;
for(unsigned int k = 0; k < 3; k++)
S[i][j] += At[i][k] * A[k][j];
}
for(unsigned int i = 0; i < 3; i++)
for(unsigned int j = i; j < 3; j++)
{
S[i][j] = S[j][i] = 0.5*(S[i][j] + S[j][i]);
}
}