本文整理汇总了C++中OoqpVector::length方法的典型用法代码示例。如果您正苦于以下问题:C++ OoqpVector::length方法的具体用法?C++ OoqpVector::length怎么用?C++ OoqpVector::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OoqpVector
的用法示例。
在下文中一共展示了OoqpVector::length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: componentMult
void SimpleVector::componentMult( OoqpVector& vec )
{
assert( n == vec.length() );
SimpleVector & sv = dynamic_cast<SimpleVector &>(vec);
double * y = sv.v;
int i;
for( i = 0; i < n; i++ ) v[i] *= y[i];
}
示例2: axdzpy
void SimpleVector::axdzpy( double alpha, OoqpVector& xvec,
OoqpVector& zvec )
{
SimpleVector & sxvec = dynamic_cast<SimpleVector &>(xvec);
double * x = sxvec.v;
SimpleVector & szvec = dynamic_cast<SimpleVector &>(zvec);
double * z = szvec.v;
assert( n == xvec.length() &&
n == zvec.length() );
int i;
for( i = 0; i < n; i++ ) {
//if(x[i] > 0 && z[i] > 0)
v[i] += alpha * x[i] / z[i];
}
}
示例3: axpy
void SimpleVector::axpy( double alpha, OoqpVector& vec )
{
assert( n == vec.length() );
SimpleVector & sv = dynamic_cast<SimpleVector &>(vec);
int one = 1;
daxpy_( &n, &alpha, sv.v, &one, v, &one );
}
示例4: componentDiv
void SimpleVector::componentDiv ( OoqpVector& vec )
{
assert( n == vec.length() );
double * pv = v, *lv = v + n;
SimpleVector & sv = dynamic_cast<SimpleVector &>(vec);
double * y = sv.v;
for( ; pv < lv; pv++, y++ ) *pv /= *y;
}
示例5: selectNonZeros
void SimpleVector::selectNonZeros( OoqpVector& select )
{
SimpleVector & sselect = dynamic_cast<SimpleVector &>(select);
double * map = sselect.v;
assert( n == select.length() );
int i;
for( i = 0; i < n; i++ ) {
if( 0.0 == map[i] ) v[i] = 0.0;
}
}
示例6: addSomeConstants
void SimpleVector::addSomeConstants( double c, OoqpVector& select )
{
SimpleVector & sselect = dynamic_cast<SimpleVector &>(select);
double * map = sselect.v;
int i;
assert( n == select.length() );
for( i = 0; i < n; i++ ) {
if( map[i] ) v[i] += c;
}
}
示例7: divideSome
void SimpleVector::divideSome( OoqpVector& div, OoqpVector& select )
{
if( n == 0 ) return;
SimpleVector & sselect = dynamic_cast<SimpleVector &>(select);
double * map = sselect.v;
SimpleVector & sdiv = dynamic_cast<SimpleVector &>(div);
double * q = sdiv.v;
assert( n == div.length() && n == select.length() );
double * lmap = map + n;
double * w = v;
while( map < lmap ) {
if( 0 != *map ) {
*w /= *q;
}
map++;
w++;
q++;
}
}
示例8: fromGetDiagonal
void DenseStorage::fromGetDiagonal( int idiag, OoqpVector& vec )
{
int k;
int extent = vec.length();
assert( idiag + extent <= n );
assert( idiag + extent <= m );
SimpleVector & sv = (SimpleVector &) vec;
for ( k = idiag; k < idiag + extent; k++ ) {
sv[k] = M[k][k];
}
}
示例9: copyFrom
void PetscVector::copyFrom( OoqpVector& v_in )
{
assert( n == v_in.length() );
if( v_in.isKindOf( kPetscVector ) ) {
PetscVector & pet = (PetscVector &) v_in;
int ierr = VecCopy( pet.pv, pv );
assert( ierr == 0);
} else if ( v_in.isKindOf( kSimpleVector ) ) {
SimpleVector & sv = (SimpleVector &) v_in;
this->copyFromArray( sv.elements() );
} else {
assert( 0 && "Can't copy from unknown OoqpVector type" );
}
}
示例10: somePositive
int SimpleVector::somePositive( OoqpVector& select )
{
SimpleVector & sselect = dynamic_cast<SimpleVector &>(select);
double * map = sselect.v;
assert( n == select.length() );
int i;
for( i = 0; i < n; i++ ) {
if( 0.0 != map[i] && v[i] <= 0 ) {
cout << "Element " << i << " is nonpositive: " << v[i] << endl;
return 0;
}
}
return 1;
}
示例11: matchesNonZeroPattern
int SimpleVector::matchesNonZeroPattern( OoqpVector& select )
{
SimpleVector & sselect = dynamic_cast<SimpleVector &>(select);
double * map = sselect.v;
double * lmap = map + n;
assert( n == select.length() );
double *w = v;
while( map < lmap ) {
if( *map == 0.0 && *w != 0.0 ) return 0;
map++;
w++;
}
return 1;
}
示例12: setToDiagonal
void DenseStorage::setToDiagonal( OoqpVector& vec )
{
int i,k;
int extent = vec.length();
assert( extent <= n );
assert( extent <= m );
SimpleVector & sv = (SimpleVector &) vec;
for( i = 0; i < m; i++ ) {
for( k = 0; k < n; k++ ) {
M[i][k] = 0.0;
}
}
for ( k = 0; k < extent; k++ ) {
M[k][k] = sv[k];
}
}
示例13: stepbound
double SimpleVector::stepbound(OoqpVector & pvec, double maxStep )
{
assert( n == pvec.length() );
SimpleVector & spvec = dynamic_cast<SimpleVector &>(pvec);
double * p = spvec.v;
double * w = v;
double bound = maxStep;
int i;
for( i = 0; i < n; i++ ) {
double temp = p[i];
if( w[i] >= 0 && temp < 0 ) {
temp = -w[i]/temp;
if( temp < bound ) {
bound = temp;
}
}
}
return bound;
}
示例14: assert
double
SimpleVector::shiftedDotProductWith( double alpha, OoqpVector& mystep,
OoqpVector& yvec,
double beta, OoqpVector& ystep )
{
assert( n == mystep.length() &&
n == yvec .length() &&
n == ystep .length() );
SimpleVector & syvec = dynamic_cast<SimpleVector &>(yvec);
double * y = syvec.v;
SimpleVector & smystep = dynamic_cast<SimpleVector &>(mystep);
double * p = smystep.v;
SimpleVector & systep = dynamic_cast<SimpleVector &>(ystep);
double * q = systep.v;
double dot1 = 0.0;
double dot2 = 0.0;
const int size = 8196;
int kmax = n / size;
int i = 0;
int k, imax;
for( k = 0; k < kmax; k++ ) {
imax = (k + 1) * 8196;
for( ; i < imax; i++ ) {
dot1 += (v[i] + alpha * p[i]) * (y[i] + beta * q[i] );
}
dot2 += dot1;
dot1 = 0;
}
for( ; i < n; i++ ) {
dot1 += (v[i] + alpha * p[i]) * (y[i] + beta * q[i] );
}
return dot2 + dot1;
}
示例15: writefSomeToStream
void SimpleVector::writefSomeToStream( ostream& out,
const char format[],
OoqpVector& select ) const
{
SimpleVector & sselect = dynamic_cast<SimpleVector &>(select);
double * s = 0;
if( select.length() > 0 ) {
s = sselect.v;
}
int i;
for( i = 0; i < n; i++ ) {
if( !s || s[i] != 0.0 ) {
int j = 0;
char c;
while( (c = format[j]) != 0 ) {
if( c != '%' ) {
out << c;
} else {
// Brain-dead variable substitution, but good enough for this
// simple case
if( 0 == strncmp( "{value}", &format[j + 1], 7 ) ) {
out << v[i];
j += 7;
} else if ( 0 == strncmp( "{index}", &format[j + 1], 7 ) ) {
out << i;
j += 7;
} else {
out << c;
}
}
j++;
}
out << endl;
}
}
}