Exemplo n.º 1
0
double Matrix::average() const
{
    if (isUniform()) {
        return getUniformValue();
    } else {
        const int dev = computeStrategy1();
        readLock(dev);
        const double avg = matty::getDevice(dev)->average(getArray(dev));
        readUnlock(dev);
        return avg;
    }
}
Exemplo n.º 2
0
double Matrix::sum() const
{
    if (isUniform()) {
        return getUniformValue() * getShape().getNumEl();
    } else {
        const int dev = computeStrategy1();
        readLock(dev);
        const double sum = matty::getDevice(dev)->sum(getArray(dev));
        readUnlock(dev);
        return sum;
    }
}
Exemplo n.º 3
0
double Matrix::minimum() const
{
    if (isUniform()) {
        return getUniformValue();
    } else {
        const int dev = computeStrategy1();
        readLock(dev);
        const double min = matty::getDevice(dev)->minimum(getArray(dev));
        readUnlock(dev);
        return min;
    }
}
Exemplo n.º 4
0
void VectorMatrix::normalize(const Matrix &len)
{
	if (isUniform() && len.isUniform()) {
		Vector3d uni = getUniformValue();
		uni.normalize(len.getUniformValue());
		fill(uni);
	} else {
		const int dev = computeStrategy2(len);
		writeLock(dev); len.readLock(dev);
		getDevice(dev)->normalize3(getArray(dev, 0), getArray(dev, 1), getArray(dev, 2), len.getArray(dev));
		len.readUnlock(dev); writeUnlock(dev); 
	}
}
Exemplo n.º 5
0
void Matrix::scale(double factor)
{
    if (factor == 0.0) {
        fill(0.0);
    } else if (isUniform()) {
        fill(getUniformValue() * factor);
    } else {
        const int dev = computeStrategy1();
        readLock(dev);
        matty::getDevice(dev)->scale(getArray(dev), factor);
        readUnlock(dev);
    }
}
Exemplo n.º 6
0
double VectorMatrix::absMax() const
{
	if (isUniform()) {
		const double x = uval[0], y = uval[1], z = uval[2];
		return std::sqrt(x*x+y*y+z*z);
	} else {
		const int dev = computeStrategy1();
		readLock(dev); 
		const double max = matty::getDevice(dev)->absmax3(
			this->getArray(dev, 0), this->getArray(dev, 1), this->getArray(dev, 2)
		);
		readUnlock(dev);
		return max;
	}
}
Exemplo n.º 7
0
void VectorMatrix::add(const VectorMatrix &op, double factor)
{
	if (this == &op) {
		scale(1.0 + factor);
	} else if (isUniform() && op.isUniform()) {
		fill(getUniformValue() + op.getUniformValue() * factor);
	} else {
		const int dev = computeStrategy2(op);
		writeLock(dev); op.readLock(dev);
		for (int c=0; c<num_arrays; ++c) {
			matty::getDevice(dev)->add(getArray(dev, c), op.getArray(dev, c), factor);
		}
		writeUnlock(dev); op.readUnlock(dev);
	}
}
Exemplo n.º 8
0
void VectorMatrix::scale(double factor)
{
	if (factor == 0.0) {
		fill(Vector3d(0.0, 0.0, 0.0));
	} else if (isUniform()) {
		fill(getUniformValue() * factor);
	} else {
		const int dev = computeStrategy1();
		readLock(dev);
		for (int c=0; c<num_arrays; ++c) {
			matty::getDevice(dev)->scale(getArray(dev, c), factor);
		}
		readUnlock(dev);
	}
}
Exemplo n.º 9
0
void aiContext::getTimeSampling(int i, aiTimeSamplingData& dst)
{
    auto ts = m_archive.getTimeSampling(i);
    auto tst = ts->getTimeSamplingType();

    dst.numTimes = (int)ts->getNumStoredTimes();
    if (tst.isUniform() || tst.isCyclic()) {
        int numCycles = int(m_archive.getMaxNumSamplesForTimeSamplingIndex(i) / tst.getNumSamplesPerCycle());

        dst.type = tst.isUniform() ? aiTimeSamplingType_Uniform : aiTimeSamplingType_Cyclic;
        dst.interval = (float)tst.getTimePerCycle();
        dst.startTime = (float)ts->getStoredTimes()[0];
        dst.endTime = dst.startTime + dst.interval * (numCycles - 1);
        dst.numTimes = (int)ts->getNumStoredTimes();
        dst.times = const_cast<double*>(&ts->getStoredTimes()[0]);
    }
    else if (tst.isAcyclic()) {
        dst.type = aiTimeSamplingType_Acyclic;
        dst.startTime = (float)ts->getSampleTime(0);
        dst.endTime = (float)ts->getSampleTime(ts->getNumStoredTimes() - 1);
        dst.numTimes = (int)ts->getNumStoredTimes();
        dst.times = const_cast<double*>(&ts->getStoredTimes()[0]);
    }
}
Exemplo n.º 10
0
Vector3d VectorMatrix::average() const
{
	if (isUniform()) {
		return getUniformValue();
	} else {
		const int dev = computeStrategy1();
		readLock(dev);
		const Vector3d avg(
			matty::getDevice(dev)->average(getArray(dev, 0)),
			matty::getDevice(dev)->average(getArray(dev, 1)),
			matty::getDevice(dev)->average(getArray(dev, 2))
		);
		readUnlock(dev);
		return avg;
	}
}
Exemplo n.º 11
0
Vector3d VectorMatrix::maximum() const
{
	if (isUniform()) {
		return getUniformValue();
	} else {
		const int dev = computeStrategy1();
		readLock(dev);
		const Vector3d max(
			matty::getDevice(dev)->maximum(getArray(dev, 0)),
			matty::getDevice(dev)->maximum(getArray(dev, 1)),
			matty::getDevice(dev)->maximum(getArray(dev, 2))
		);
		readUnlock(dev);
		return max;
	}
}
Exemplo n.º 12
0
void VectorMatrix::scale(const Vector3d &factors)
{
	if (factors == Vector3d(0.0, 0.0, 0.0)) {
		fill(Vector3d(0.0, 0.0, 0.0));
	} else if (isUniform()) {
		const Vector3d uni = getUniformValue();
		fill(Vector3d(uni.x*factors.x, uni.y*factors.y, uni.z*factors.z));
	} else {
		const int dev = computeStrategy1();
		readLock(dev);
		matty::getDevice(dev)->scale(getArray(dev, 0), factors.x);
		matty::getDevice(dev)->scale(getArray(dev, 1), factors.y);
		matty::getDevice(dev)->scale(getArray(dev, 2), factors.z);
		readUnlock(dev);
	}
}
Exemplo n.º 13
0
Vector3d VectorMatrix::sum() const
{
	if (isUniform()) {
		return getUniformValue() * getShape().getNumEl();
	} else {
		const int dev = computeStrategy1();
		readLock(dev);
		
		const Vector3d sum(
			matty::getDevice(dev)->sum(getArray(dev, 0)),
			matty::getDevice(dev)->sum(getArray(dev, 1)),
			matty::getDevice(dev)->sum(getArray(dev, 2))
		);
		readUnlock(dev);
		return sum;
	}
}
Exemplo n.º 14
0
double VectorMatrix::dotSum(const VectorMatrix &other) const
{
	if (isUniform() && other.isUniform()) {
		const double x = uval[0], y = uval[1], z = uval[2];
		const double dot = x*x + y*y + z*z;
		return size() * dot;
	} else {
		const int dev = computeStrategy2(other);
		readLock(dev); if (this != &other) other.readLock(dev);
		const double sum = matty::getDevice(dev)->sumdot3(
			this->getArray(dev, 0), this->getArray(dev, 1), this->getArray(dev, 2),
			other.getArray(dev, 0), other.getArray(dev, 1), other.getArray(dev, 2)
		);
		if (this != &other) other.readUnlock(dev); readUnlock(dev);
		return sum;
	}
}
Exemplo n.º 15
0
bool ShVarItem::isActiveUniform(void)
{
	return isUniform() && data(DF_DEBUG_UNIFORM_VALUE) != QVariant();
}
Exemplo n.º 16
0
double Matrix::getUniformValue() const
{
    if (!isUniform()) throw std::runtime_error("Cant get uniform value because matrix is not uniform");
    return uval[0];
}
Exemplo n.º 17
0
Vector3d VectorMatrix::getUniformValue() const
{
	if (!isUniform()) throw std::runtime_error("Can't get uniform value because matrix is not uniform");
	return Vector3d(uval[0], uval[1], uval[2]);
}
Exemplo n.º 18
0
bool Selection::isMeetable() const{
	return
		isUniform() &&
		isCommandable() &&
		selectedUnits.front()->getType()->getMeetingPoint();
}