Пример #1
0
bool AMInMemoryDataStore::setValue(const AMnDIndex &scanIndex, int measurementId, const double *inputData) {
	// scan axis index doesn't provide enough / too many dimensions
	if(scanIndex.rank() != axes_.count())
		return false;

	if((unsigned)measurementId >= (unsigned)measurements_.count())
		return false;	// invalid measurement specified;

	// scalar scan space:
	if(axes_.count() == 0) {
		AMIMDSMeasurement& measurement = scalarScanPoint_[measurementId];
		for(int i=0,cc=measurement.size(); i<cc; ++i)
			measurement[i] = inputData[i];
	}
	// higher dimension scan space:
	else {
		int flatScanIndex = scanIndex.flatIndexInArrayOfSize(scanSize_);
#ifdef AM_ENABLE_BOUNDS_CHECKING
		if(flatScanIndex >= scanPoints_.count())
			return false;
#endif
		AMIMDSMeasurement& measurement = scanPoints_[flatScanIndex][measurementId];
		for(int i=0,cc=measurement.size(); i<cc; ++i)
			measurement[i] = inputData[i];
	}

	emitDataChanged(scanIndex, scanIndex, measurementId);
	return true;
}
Пример #2
0
bool AMInMemoryDataStore::setValue(const AMnDIndex &scanIndex, int measurementId, const AMnDIndex &measurementIndex, const AMNumber &newValue) {

	if(scanIndex.rank() != axes_.count())
		return false; // scan axis index doesn't provide enough / too many dimensions

	if((unsigned)measurementId >= (unsigned)measurements_.count())
		return false;	// invalid measurement specified;

	if(measurementIndex.rank() != measurements_.at(measurementId).rank())
		return false;

	int flatMeasurementIndex = flatIndexForMeasurement(measurementId, measurementIndex);

	if(axes_.count() == 0) {
#ifdef AM_ENABLE_BOUNDS_CHECKING
		if(flatMeasurementIndex >= scalarScanPoint_.at(measurementId).size())
			return false;
#endif
		scalarScanPoint_[measurementId][flatMeasurementIndex] = newValue;
	}
	else { // higher dimensions:
		int flatScanIndex = scanIndex.flatIndexInArrayOfSize(scanSize_);
#ifdef AM_ENABLE_BOUNDS_CHECKING
		if(flatScanIndex >= scanPoints_.count())
			return false;
		if(flatMeasurementIndex >= scanPoints_.at(flatScanIndex).at(measurementId).size())
			return false;
#endif
		scanPoints_[flatScanIndex][measurementId][flatMeasurementIndex] = newValue;
	}

	emitDataChanged(scanIndex, scanIndex, measurementId);
	return true;
}
Пример #3
0
AMNumber AMInMemoryDataStore::value(const AMnDIndex &scanIndex, int measurementId, const AMnDIndex &measurementIndex) const {

	// scan axis index doesn't provide enough / too many dimensions
	if(scanIndex.rank() != axes_.count())
		return AMNumber(AMNumber::DimensionError);

	if((unsigned)measurementId >= (unsigned)measurements_.count())
		return AMNumber(AMNumber::InvalidError);	// invalid measurement specified;

	if(measurementIndex.rank() != measurements_.at(measurementId).rank())
		return AMNumber(AMNumber::DimensionError);

	int flatMeasurementIndex = flatIndexForMeasurement(measurementId, measurementIndex);

	if(axes_.count() == 0) {
#ifdef AM_ENABLE_BOUNDS_CHECKING
		if(flatMeasurementIndex >= scalarScanPoint_.at(measurementId).size())
			return AMNumber(AMNumber::OutOfBoundsError);
#endif
		return scalarScanPoint_.at(measurementId).at(flatMeasurementIndex);
	}
	else { // higher dimensions:
		int flatScanIndex = scanIndex.flatIndexInArrayOfSize(scanSize_);
#ifdef AM_ENABLE_BOUNDS_CHECKING
		if(flatScanIndex >= scanPoints_.count())
			return AMNumber(AMNumber::OutOfBoundsError);
		if(flatMeasurementIndex >= scanPoints_.at(flatScanIndex).at(measurementId).size())
			return AMNumber(AMNumber::OutOfBoundsError);
#endif
		return scanPoints_.at(flatScanIndex).at(measurementId).at(flatMeasurementIndex);
	}
}
Пример #4
0
void AM3DAdditionAB::computeCachedValues() const
{
	AMnDIndex start = AMnDIndex();
	AMnDIndex end = AMnDIndex();

	if (dirtyIndices_.isEmpty()){

		start = AMnDIndex(rank(), AMnDIndex::DoInit);
		end = size()-1;
	}

	else {

		start = dirtyIndices_.first();
		end = dirtyIndices_.last();
		end[rank()-1] = size(rank()-1);
	}

	int totalSize = start.totalPointsTo(end);
	int flatStartIndex = start.flatIndexInArrayOfSize(size());
	QVector<double> data = QVector<double>(totalSize);
	sources_.at(0)->values(start, end, data.data());

	// Do the first data source separately to initialize the values.
	memcpy(cachedData_.data()+flatStartIndex, data.constData(), totalSize*sizeof(double));
	cachedData_ = data;

	// Iterate through the rest of the sources.
	for (int i = 1, count = sources_.size(); i < count; i++){

		sources_.at(i)->values(start, end, data.data());

		for (int j = 0; j < totalSize; j++)
			cachedData_[flatStartIndex+j] += data.at(j);
	}

	if (dirtyIndices_.isEmpty())
		cachedDataRange_ = AMUtility::rangeFinder(cachedData_);

	else{
		AMRange cachedRange = AMUtility::rangeFinder(cachedData_.mid(flatStartIndex, totalSize));

		if (cachedDataRange_.minimum() > cachedRange.minimum())
			cachedDataRange_.setMinimum(cachedRange.minimum());

		if (cachedDataRange_.maximum() < cachedRange.maximum())
			cachedDataRange_.setMaximum(cachedRange.maximum());
	}

	cacheUpdateRequired_ = false;
	dirtyIndices_.clear();
}
Пример #5
0
AMNumber AMNormalizationAB::value(const AMnDIndex &indexes) const
{
	if(indexes.rank() != rank())
		return AMNumber(AMNumber::DimensionError);

	if(!isValid())
		return AMNumber(AMNumber::InvalidError);

	for (int i = 0, size = indexes.rank(); i < size; i++)
		if((unsigned)indexes.at(i) >= (unsigned)axes_.at(i).size)
			return AMNumber(AMNumber::OutOfBoundsError);

	if (cacheUpdateRequired_)
		computeCachedValues();

	return cachedData_.at(indexes.flatIndexInArrayOfSize(size()));
}
Пример #6
0
bool AMNormalizationAB::values(const AMnDIndex &indexStart, const AMnDIndex &indexEnd, double *outputValues) const
{
	if(indexStart.rank() != rank() || indexEnd.rank() != rank())
		return false;

	if(!isValid())
		return false;

	for (int i = 0, size = indexStart.rank(); i < size; i++)
		if((unsigned)indexStart.at(i) >= (unsigned)axes_.at(i).size || (unsigned)indexStart.at(i) > (unsigned)indexEnd.at(i))
			return false;

	if (cacheUpdateRequired_)
		computeCachedValues();

	int totalSize = indexStart.totalPointsTo(indexEnd);
	memcpy(outputValues, cachedData_.constData()+indexStart.flatIndexInArrayOfSize(size()), totalSize*sizeof(double));

	return true;
}