本文整理汇总了C++中KstMatrixPtr::setValueRaw方法的典型用法代码示例。如果您正苦于以下问题:C++ KstMatrixPtr::setValueRaw方法的具体用法?C++ KstMatrixPtr::setValueRaw怎么用?C++ KstMatrixPtr::setValueRaw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KstMatrixPtr
的用法示例。
在下文中一共展示了KstMatrixPtr::setValueRaw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: binnedmap
//.........这里部分代码省略.........
if (_autoBin) {
double minx, miny, maxx, maxy;
int nx, ny;
autoSize(X(), Y(), &nx, &minx, &maxx, &ny, &miny, &maxy);
setNX(nx);
setNY(ny);
setXMin(minx);
setXMax(maxx);
setYMin(miny);
setYMax(maxy);
} else {
KstScalarPtr xmin = *_inputScalars.find(XMIN);
KstScalarPtr xmax = *_inputScalars.find(XMAX);
KstScalarPtr ymin = *_inputScalars.find(YMIN);
KstScalarPtr ymax = *_inputScalars.find(YMAX);
KstScalarPtr nx = *_inputScalars.find(NX);
KstScalarPtr ny = *_inputScalars.find(NY);
if (xmin) {
_xMin = xmin->value();
}
if (xmax) {
_xMax = xmax->value();
}
if (ymin) {
_yMin = ymin->value();
}
if (ymax) {
_yMax = ymax->value();
}
if (nx) {
_nx = (int)nx->value();
}
if (ny) {
_ny = (int)ny->value();
}
}
bool needsresize = false;
if (_nx < 2) {
_nx = 2;
needsresize = true;
}
if (_ny < 2) {
_ny = 2;
needsresize = true;
}
if ((map->xNumSteps() != _nx) || (map->yNumSteps() != _ny) ||
(map->minX() != _xMin) || (map->minY() != _yMin)) {
needsresize = true;
}
if (map->xStepSize() != (_xMax - _xMin)/double(_nx-1)) {
needsresize = true;
}
if (map->yStepSize() != (_yMax - _yMin)/double(_ny-1)) {
needsresize = true;
}
if (needsresize) {
map->change(map->tag(), _nx, _ny, _xMin, _yMin,
(_xMax - _xMin)/double(_nx-1), (_yMax - _yMin)/double(_ny-1));
map->resize(_nx, _ny);
hitsMap->change(hitsMap->tag(), _nx, _ny, _xMin, _yMin,
(_xMax - _xMin)/double(_nx-1), (_yMax - _yMin)/double(_ny-1));
hitsMap->resize(_nx, _ny);
}
map->zero();
hitsMap->zero();
int ns = z->length(); // the z vector defines the number of points.
double n,p, x0, y0, z0;
for (int i=0; i<ns; i++) {
x0 = x->interpolate(i, ns);
y0 = y->interpolate(i, ns);
z0 = z->interpolate(i, ns);
p = map->value(x0, y0)+z0;
map->setValue(x0, y0, p);
n = hitsMap->value(x0, y0)+1;
hitsMap->setValue(x0, y0, n);
}
for (int i=0; i<_nx; i++) {
for (int j=0; j<_ny; j++) {
p = map->valueRaw(i, j);
n = hitsMap->valueRaw(i, j);
if (n>0) {
map->setValueRaw(i, j, p/n);
} else {
map->setValueRaw(i, j, KST::NOPOINT);
}
}
}
}
示例2: binnedmap
void BinnedMap::binnedmap() {
KstVectorPtr x = *_inputVectors.find(VECTOR_X);
KstVectorPtr y = *_inputVectors.find(VECTOR_Y);
KstVectorPtr z = *_inputVectors.find(VECTOR_Z);
KstMatrixPtr map = *_outputMatrices.find(MAP);
KstMatrixPtr hitsMap = *_outputMatrices.find(HITSMAP);
if (autoBin()) {
AutoSize(X(),Y(), &_nx, &_xMin, &_xMax, &_ny, &_yMin, &_yMax);
}
bool needsresize = false;
if (_nx<2) {
_nx = 2;
needsresize = true;
}
if (_ny<2) {
_ny = 2;
needsresize = true;
}
if ((map->xNumSteps() != _nx) || (map->yNumSteps() != _ny) ||
(map->minX() != _xMin) || (map->minY() != _yMin)) {
needsresize = true;
}
if (map->xStepSize() != (_xMax - _xMin)/double(_nx-1)) {
needsresize = true;
}
if (map->yStepSize() != (_yMax - _yMin)/double(_ny-1)) {
needsresize = true;
}
if (needsresize) {
map->change(map->tag(), _nx, _ny, _xMin, _yMin,
(_xMax - _xMin)/double(_nx-1), (_yMax - _yMin)/double(_ny-1));
map->resize(_nx, _ny);
hitsMap->change(hitsMap->tag(), _nx, _ny, _xMin, _yMin,
(_xMax - _xMin)/double(_nx-1), (_yMax - _yMin)/double(_ny-1));
hitsMap->resize(_nx, _ny);
}
map->zero();
hitsMap->zero();
int ns = z->length(); // the z vector defines the number of points.
double n,p, x0, y0, z0;
for (int i=0; i<ns; i++) {
x0 = x->interpolate(i, ns);
y0 = y->interpolate(i, ns);
z0 = z->interpolate(i, ns);
p = map->value(x0, y0)+z0;
map->setValue(x0, y0, p);
n = hitsMap->value(x0, y0)+1;
hitsMap->setValue(x0, y0, n);
}
for (int i=0; i<_nx; i++) {
for (int j=0; j<_ny; j++) {
p = map->valueRaw(i,j);
n = hitsMap->valueRaw(i,j);
if (n>0) {
map->setValueRaw(i,j,p/n);
} else {
map->setValueRaw(i,j,KST::NOPOINT);
}
}
}
//calculate here...
}
示例3: doTests
void doTests() {
bool ok = true;
//basic default constructor values
KstMatrixPtr m1 = new KstMatrix(KstObjectTag(QString::null));
doTest(m1->tagName().startsWith("Anonymous"));
doTest(m1->sampleCount() == 0);
doTest(m1->minValue() == 0);
doTest(m1->maxValue() == 0);
doTest(m1->value(0, 0, &ok) == 0);
doTest(!ok);
doTest(m1->value(10, 10, &ok) == 0); //should be outside the boundaries.
doTest(!ok);
doTest(m1->sampleCount() == 0);
doTest(m1->meanValue() != m1->meanValue()); // NaN
//basic symetrical matrix
KstMatrixPtr m2 = new KstMatrix(KstObjectTag("Symetrical"), 0L, 3, 3);
doTest(m2->tagName() == "Symetrical");
doTest(m2->resize(3, 3, true));
doTest(!m2->editable());
m2->setEditable(true);
doTest(m2->editable());
doTest(m2->xNumSteps() == 3);
doTest(m2->yNumSteps() == 3);
doTest(m2->minX() == 0);
doTest(m2->minY() == 0);
doTest(m2->xStepSize() == 1);
doTest(m2->yStepSize() == 1);
doTest(m2->sampleCount() == 9);
doTest(m2->setValueRaw(1, 1, 5));
ok = true;
doTest(m2->value(1, 1, &ok) == 5);
doTest(ok);
m2->blank();
m2->change(m2->tag(), 3, 3, 0, 0, 0, 0); //should not be legal
doTest(m2->xNumSteps() == 3);
doTest(m2->yNumSteps() == 3);
doTest(m2->minX() == 0);
doTest(m2->minY() == 0);
doTest(m2->xStepSize() == 0);
doTest(m2->yStepSize() == 0);
doTest(m2->sampleCount() == 9);
doTest(!m2->setValue(0, 0, 1.0));
ok = true;
doTest(m2->value(0, 0, &ok) == 0.0);
doTest(!ok);
doTest(!m2->setValue(1, 1, 5.0));
doTest(m2->value(1, 1) != 5.0);
doTest(m2->setValueRaw(2, 2, 6.0)); //fails
KstMatrixPtr um1 = new KstMatrix(KstObjectTag("Unity"), 0L, 3, 3, 0, 0, 1, 1);
um1->setEditable(true);
um1->zero();
doTest(!um1->setValue(0, 0, 1.0));
doTest(!um1->setValue(1, 1, 1.0));
doTest(!um1->setValue(2, 2, 1.0));
doTest(um1->resize(3, 3, false));
um1->zero();
doTest(um1->setValue(0, 0, 1.0));
doTest(um1->setValue(1, 1, 1.0));
doTest(um1->setValue(2, 2, 1.0));
// calling resize on a matrix does not retain the correct values
// for matrix entries. i.e. taking a 3x3 matrix and resizing
// to a 2x2 matrix does not mean matrix[0][0], matrix[0][1],
// matrix[1][0], matrix[1][1] are the same before and after the resize.
// The resulting values should properly be undefined...
doTest(um1->resize(2, 2, true));
doTest(um1->sampleCount() == 4);
doTest(um1->value(0, 0, &ok) == 1.0);
doTest(ok);
doTest(um1->value(0, 1, &ok) == 0);
doTest(ok);
doTest(um1->value(0, 2, &ok) == 0);
doTest(!ok);
doTest(um1->value(1, 0, &ok) == 0);
doTest(ok);
doTest(um1->value(1, 1, &ok) == 0);
doTest(ok);
doTest(um1->value(1, 2, &ok) == 0);
doTest(!ok);
doTest(um1->resize(4, 4, false));
doTest(um1->value(0, 0, &ok) == 1.0);
doTest(ok);
doTest(um1->value(0, 1, &ok) == 0);
doTest(ok);
doTest(um1->value(0, 2, &ok) == 0);
//.........这里部分代码省略.........