本文整理汇总了C++中MyT类的典型用法代码示例。如果您正苦于以下问题:C++ MyT类的具体用法?C++ MyT怎么用?C++ MyT使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MyT类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool VectorTemplate<T>::isEqual(const MyT& a,T eps) const
{
CHECKEMPTY();
Assert(size()==a.size());
ItT v=begin();
ItT va=a.begin();
for(int i=0;i<n;i++,v++,va++)
if(!FuzzyEquals(*v,*va,eps)) return false;
return true;
}
示例2: if
void DiagonalMatrixTemplate<T>::setPseudoInverse(const MyT& a)
{
if(this->empty())
resize(a.n);
else if(this->size() != a.size()) {
RaiseErrorFmt(WHERE_AM_I,MatrixError_IncompatibleDimensions,this->n,this->n,a.n,a.n);
}
ItT v=this->begin();
ItT va=a.begin();
for(int i=0; i<this->n; i++,v++,va++)
*v = PseudoInv(*va);
}
示例3: if
T SparseVectorCompressed<T>::distanceSquared(const MyT& rhs) const
{
Assert(isValid() && rhs.isValid());
Assert(n == rhs.n);
int ak=0,bk=0;
int ai,bi;
T res = 0;
while(ak<num_entries || bk<rhs.num_entries) {
ai = (ak<num_entries? indices[ak] : n);
bi = (bk<rhs.num_entries? rhs.indices[bk] : n);
if(ai < bi) {
res += Sqr(vals[ak]);
ak++;
}
else if(bi < ai) {
res += Sqr(rhs.vals[bk]);
bk++;
}
else {
res += Sqr(vals[ak]-rhs.vals[bk]);
ak++; bk++;
}
}
return res;
}
示例4: Assert
void VectorTemplate<T>::copySubVector(int i,const MyT& a)
{
Assert(this != &a);
Assert(isValidIndex(i));
Assert(isValidIndex(i+a.n-1));
gen_array_equal(getStart()+i*stride,stride, a.getStart(),a.stride, a.n);
}
示例5: Assert
void MatrixTemplate<T>::setRef(const MyT& mat,int i,int j,int _istride,int _jstride,int _m,int _n)
{
Assert(this != &mat);
Assert(!allocated);
vals = mat.vals;
capacity = mat.capacity;
allocated = false;
base = mat.base+i*mat.istride+j*mat.jstride;
istride = _istride*mat.istride;
jstride = _jstride*mat.jstride;
if(mat.isEmpty()) {
Assert(_m <= 0 && _n <= 0);
if(_m < 0) m = mat.m;
else m=0;
if(_n < 0) n = mat.n;
else n=0;
Assert(isValid());
return;
}
if(_m < 0) {
Assert(istride != 0);
m = (mat.m-i+_istride-1) / _istride;
}
else
m = _m;
if(_n < 0) {
Assert(jstride != 0);
n = (mat.n-j+_jstride-1) / _jstride;
}
else
n = _n;
Assert(isValid());
}
示例6: CHECKSIZE
void VectorTemplate<T>::swapCopy(MyT& a)
{
CHECKSIZE(a.n);
T tmp;
ItT v=begin();
ItT va=a.begin();
for(int i=0;i<n;i++,v++,va++) {
tmp = *v; *v = *va; *va = tmp;
}
}
示例7: CHECKDIMS
void MatrixTemplate<T>::swapCopy(MyT& a)
{
CHECKDIMS(a.m,a.n);
T tmp;
ItT v=begin();
ItT va=a.begin();
for(int i=0;i<m;i++,v.nextRow(),va.nextRow()) {
for(int j=0;j<n;j++,v.nextCol(),va.nextCol()) {
tmp=*v; *v=*va; *va=tmp;
}
}
}
示例8: CHECKEMPTY
bool MatrixTemplate<T>::isEqual(const MyT& a,T eps) const
{
CHECKEMPTY();
CHECKDIMS(a.m,a.n);
ItT v=begin();
ItT va=a.begin();
for(int i=0;i<m;i++,v.nextRow(),va.nextRow())
for(int j=0;j<n;j++,v.nextCol(),va.nextCol())
if(!FuzzyEquals(*v,*va,eps))
return false;
return true;
}
示例9: gen_array_dot
T VectorTemplate<T>::dot(const MyT& a) const
{
CHECKEMPTY();
Assert(size()==a.size());
return gen_array_dot(getStart(),stride, a.getStart(),a.stride, n);
}
示例10: normSquared
T SparseVectorTemplate<T>::distanceSquared(const MyT& b) const
{
return normSquared() + b.normSquared() - Two*dot(b);
}
示例11: CHECKRESIZE
void VectorTemplate<T>::setNegative(const MyT& a)
{
CHECKRESIZE(a.n);
gen_array_negate(getStart(),stride, a.getStart(),a.stride, n);
}
示例12: equal
bool VectorTemplate<T>::operator == (const MyT& v) const
{
if(this == &v) return true;
if(size() != v.n) return false;
return std::equal(begin(),end(),v.begin());
}