bool CompositeIntegerGroup::IsGenerator(const Element &a) const { if(IsIdentity(Exponentiate(a, 2))) return false; if(IsIdentity(Exponentiate(a, _s))) return false; if(!IsIdentity(Exponentiate(a, _n))) return false; return true; }
bool DL_GroupParameters_EC<EC>::ValidateElement(unsigned int level, const Element &g, const DL_FixedBasePrecomputation<Element> *gpc) const { bool pass = !IsIdentity(g) && GetCurve().VerifyPoint(g); if (level >= 1) { if (gpc) pass = pass && gpc->Exponentiate(GetGroupPrecomputation(), Integer::One()) == g; } if (level >= 2) { const Integer &q = GetSubgroupOrder(); pass = pass && IsIdentity(gpc ? gpc->Exponentiate(GetGroupPrecomputation(), q) : ExponentiateElement(g, q)); } return pass; }
bool CppECGroup::IsProbablyValid() const { return IsElement(GetGenerator()) && IsIdentity(Exponentiate(GetGenerator(), GetOrder())) && CryptoPP::IsPrime(_curve.FieldSize()) && GetOrder().IsPrime(); }
// applies the matrix except for translations // | m_11 m_12 0 | // | src.m_x src._my 0 | x | m_21 m_22 0 | // | m_tx m_ty 1 | wxPoint2DDouble wxAffineMatrix2D::DoTransformDistance(const wxPoint2DDouble& src) const { if ( IsIdentity() ) return src; return wxPoint2DDouble(src.m_x * m_11 + src.m_y * m_21, src.m_x * m_12 + src.m_y * m_22); }
// applies that matrix to the point // | m_11 m_12 0 | // | src.m_x src._my 1 | x | m_21 m_22 0 | // | m_tx m_ty 1 | wxPoint2DDouble wxAffineMatrix2D::DoTransformPoint(const wxPoint2DDouble& src) const { if ( IsIdentity() ) return src; return wxPoint2DDouble(src.m_x * m_11 + src.m_y * m_21 + m_tx, src.m_x * m_12 + src.m_y * m_22 + m_ty); }
void hsMatrix44::Write(hsStream *stream) { bool ident = IsIdentity(); stream->WriteBool(!ident); if (!ident) { int i,j; for(i=0; i<4; i++) for(j=0; j<4; j++) stream->WriteLEFloat(fMap[i][j]); } }
// Transform a point from logical to device coordinates bool wxTransformMatrix::TransformPoint(double x, double y, double& tx, double& ty) const { if (IsIdentity()) { tx = x; ty = y; return true; } tx = x * m_matrix[0][0] + y * m_matrix[1][0] + m_matrix[2][0]; ty = x * m_matrix[0][1] + y * m_matrix[1][1] + m_matrix[2][1]; return true; }
void hsMatrix44::Read(hsStream *stream) { if (stream->ReadBool()) { int i,j; for(i=0; i<4; i++) for(j=0; j<4; j++) fMap[i][j] = stream->ReadLEFloat(); IsIdentity(); } else Reset(); }
// Example of use: // wxTransformMatrix mat = dc.GetTransformation(); // mat.Invert(); // mat.InverseTransformPoint(x, y, x1, y1); // OR (shorthand:) // dc.LogicalToDevice(x, y, x1, y1); // The latter is slightly less efficient if we're doing several // conversions, since the matrix is inverted several times. bool wxTransformMatrix::InverseTransformPoint(double x, double y, double& tx, double& ty) const { if (IsIdentity()) { tx = x; ty = y; return true; } const double z = (1.0 - m_matrix[0][2] * x - m_matrix[1][2] * y) / m_matrix[2][2]; if ( wxIsNullDouble(z) ) return false; tx = x * m_matrix[0][0] + y * m_matrix[1][0] + z * m_matrix[2][0]; ty = x * m_matrix[0][1] + y * m_matrix[1][1] + z * m_matrix[2][1]; return true; }
bool CppECGroup::IsElement(const Element &a) const { return IsIdentity(a) || _curve.VerifyPoint(GetPoint(a)); }