示例#1
0
primitiveEqual(void)
{
    sqInt arg;
    float *argPtr;
    sqInt i;
    sqInt length;
    sqInt rcvr;
    float *rcvrPtr;

	arg = stackValue(0);
	rcvr = stackValue(1);
	if (!((isWords(arg))
		 && (isWords(rcvr)))) {
		return primitiveFail();
	}
	pop(2);
	if (!(((length = stSizeOf(arg))) == (stSizeOf(rcvr)))) {
		return pushBool(0);
	}
	rcvrPtr = ((float *) (firstIndexableField(rcvr)));
	argPtr = ((float *) (firstIndexableField(arg)));
	for (i = 0; i < length; i += 1) {
		if (!((rcvrPtr[i]) == (argPtr[i]))) {
			return pushBool(0);
		}
	}
	return pushBool(1);
}
primitiveDotProduct(void)
{
	// FloatArrayPlugin>>#primitiveDotProduct
    sqInt arg;
    float *argPtr;
    sqInt i;
    sqInt length;
    sqInt rcvr;
    float *rcvrPtr;
    double  result;

	arg = stackObjectValue(0);
	rcvr = stackObjectValue(1);
	if (failed()) {
		return null;
	}
	success(isWords(arg));
	success(isWords(rcvr));
	if (failed()) {
		return null;
	}
	length = stSizeOf(arg);
	success(length == (stSizeOf(rcvr)));
	if (failed()) {
		return null;
	}
	rcvrPtr = ((float *) (firstIndexableField(rcvr)));
	argPtr = ((float *) (firstIndexableField(arg)));
	result = 0.0;
	for (i = 0; i <= (length - 1); i += 1) {
		result += (((double) (rcvrPtr[i]))) * (((double) (argPtr[i])));
	}
	pop(2);
	pushFloat(result);
}
示例#3
0
primitiveDotProduct(void)
{
    sqInt arg;
    float *argPtr;
    sqInt i;
    sqInt length;
    sqInt rcvr;
    float *rcvrPtr;
    double result;

	arg = stackValue(0);
	rcvr = stackValue(1);
	if (!((isWords(arg))
		 && ((isWords(rcvr))
		 && (((length = stSizeOf(arg))) == (stSizeOf(rcvr)))))) {
		return primitiveFail();
	}
	rcvrPtr = ((float *) (firstIndexableField(rcvr)));
	argPtr = ((float *) (firstIndexableField(arg)));
	result = 0.0;
	for (i = 0; i < length; i += 1) {
		result += (((double) (rcvrPtr[i]))) * (((double) (argPtr[i])));
	}
	pop(2);
	pushFloat(result);
	return 0;
}
示例#4
0
primitiveDivFloatArray(void)
{
    sqInt arg;
    float *argPtr;
    sqInt i;
    sqInt length;
    sqInt rcvr;
    float *rcvrPtr;

	arg = stackValue(0);
	rcvr = stackValue(1);
	if (!((isWords(arg))
		 && ((isWords(rcvr))
		 && (((length = stSizeOf(arg))) == (stSizeOf(rcvr)))))) {
		return primitiveFail();
	}
	rcvrPtr = ((float *) (firstIndexableField(rcvr)));

	/* Check if any of the argument's values is zero */
	argPtr = ((float *) (firstIndexableField(arg)));
	for (i = 0; i < length; i += 1) {
		if ((intAtPointer(((char*) (argPtr + i)))) == 0) {
			return primitiveFail();
		}
	}
	for (i = 0; i < length; i += 1) {
		rcvrPtr[i] = ((((double) (rcvrPtr[i]))) / (((double) (argPtr[i]))));
	}
	pop(1);
	return 0;
}
primitiveEqual(void)
{
	// FloatArrayPlugin>>#primitiveEqual
    sqInt arg;
    float *argPtr;
    sqInt i;
    sqInt length;
    sqInt rcvr;
    float *rcvrPtr;

	arg = stackObjectValue(0);
	rcvr = stackObjectValue(1);
	if (failed()) {
		return null;
	}
	success(isWords(arg));
	success(isWords(rcvr));
	if (failed()) {
		return null;
	}
	pop(2);
	length = stSizeOf(arg);
	if (!(length == (stSizeOf(rcvr)))) {
		return pushBool(0);
	}
	rcvrPtr = ((float *) (firstIndexableField(rcvr)));
	argPtr = ((float *) (firstIndexableField(arg)));
	for (i = 0; i <= (length - 1); i += 1) {
		if (!((rcvrPtr[i]) == (argPtr[i]))) {
			return pushBool(0);
		}
	}
	return pushBool(1);
}
primitiveSubFloatArray(void)
{
	// FloatArrayPlugin>>#primitiveSubFloatArray
    sqInt arg;
    float *argPtr;
    sqInt i;
    sqInt length;
    sqInt rcvr;
    float *rcvrPtr;

	arg = stackObjectValue(0);
	rcvr = stackObjectValue(1);
	if (failed()) {
		return null;
	}
	success(isWords(arg));
	success(isWords(rcvr));
	if (failed()) {
		return null;
	}
	length = stSizeOf(arg);
	success(length == (stSizeOf(rcvr)));
	if (failed()) {
		return null;
	}
	rcvrPtr = ((float *) (firstIndexableField(rcvr)));
	argPtr = ((float *) (firstIndexableField(arg)));
	for (i = 0; i <= (length - 1); i += 1) {
		rcvrPtr[i] = ((((double) (rcvrPtr[i]))) - (((double) (argPtr[i]))));
	}
	pop(1);
}
示例#7
0
	/* FFTPlugin>>#loadFFTFrom: */
static sqInt
loadFFTFrom(sqInt fftOop)
{
    sqInt oop;

	success((slotSizeOf(fftOop)) >= 6);
	if (failed()) {
		return 0;
	}
	nu = fetchIntegerofObject(0, fftOop);
	fftSize = fetchIntegerofObject(1, fftOop);
	oop = fetchPointerofObject(2, fftOop);
	sinTableSize = stSizeOf(oop);
	/* begin checkedFloatPtrOf: */
	success(isWords(oop));
	if (failed()) {
		sinTable = 0;
		goto l1;
	}
	sinTable = ((float *) (firstIndexableField(oop)));
l1:	/* end checkedFloatPtrOf: */;
	oop = fetchPointerofObject(3, fftOop);
	permTableSize = stSizeOf(oop);
	/* begin checkedWordPtrOf: */
	success(isWords(oop));
	permTable = ((unsigned int *) (firstIndexableField(oop)));
	oop = fetchPointerofObject(4, fftOop);
	realDataSize = stSizeOf(oop);
	/* begin checkedFloatPtrOf: */
	success(isWords(oop));
	if (failed()) {
		realData = 0;
		goto l3;
	}
	realData = ((float *) (firstIndexableField(oop)));
l3:	/* end checkedFloatPtrOf: */;
	oop = fetchPointerofObject(5, fftOop);
	imagDataSize = stSizeOf(oop);
	/* begin checkedFloatPtrOf: */
	success(isWords(oop));
	if (failed()) {
		imagData = 0;
		goto l4;
	}
	imagData = ((float *) (firstIndexableField(oop)));
l4:	/* end checkedFloatPtrOf: */;
	success((((((1L << nu) == fftSize) && (((fftSize / 4) + 1) == sinTableSize)) && (fftSize == realDataSize)) && (fftSize == imagDataSize)) && (realDataSize == imagDataSize));
	return (failed()) == 0;
}
示例#8
0
primitiveDivScalar(void)
{
    sqInt i;
    double  inverse;
    sqInt length;
    sqInt rcvr;
    float *rcvrPtr;
    double value;

	value = stackFloatValue(0);
	if (failed()) {
		return null;
	}
	rcvr = stackValue(1);
	if (!(isWords(rcvr))) {
		return primitiveFail();
	}
	length = stSizeOf(rcvr);
	rcvrPtr = ((float *) (firstIndexableField(rcvr)));
	inverse = 1.0 / value;
	for (i = 0; i < length; i += 1) {
		rcvrPtr[i] = ((((double) (rcvrPtr[i]))) * inverse);
	}
	pop(1);
	return 0;
}
primitiveSum(void)
{
	// FloatArrayPlugin>>#primitiveSum
    sqInt i;
    sqInt length;
    sqInt rcvr;
    float *rcvrPtr;
    double  sum;

	rcvr = stackObjectValue(0);
	if (failed()) {
		return null;
	}
	success(isWords(rcvr));
	if (failed()) {
		return null;
	}
	length = stSizeOf(rcvr);
	rcvrPtr = ((float *) (firstIndexableField(rcvr)));
	sum = 0.0;
	for (i = 0; i <= (length - 1); i += 1) {
		sum += ((double) (rcvrPtr[i]));
	}
	popthenPush(1, floatObjectOf(sum));
}
primitiveSubScalar(void)
{
	// FloatArrayPlugin>>#primitiveSubScalar
    sqInt i;
    sqInt length;
    sqInt rcvr;
    float *rcvrPtr;
    double  value;

	value = stackFloatValue(0);
	rcvr = stackObjectValue(1);
	if (failed()) {
		return null;
	}
	success(isWords(rcvr));
	if (failed()) {
		return null;
	}
	length = stSizeOf(rcvr);
	rcvrPtr = ((float *) (firstIndexableField(rcvr)));
	for (i = 0; i <= (length - 1); i += 1) {
		rcvrPtr[i] = ((((double) (rcvrPtr[i]))) - value);
	}
	pop(1);
}
primitiveNormalize(void)
{
	// FloatArrayPlugin>>#primitiveNormalize
    sqInt i;
    double  len;
    sqInt length;
    sqInt rcvr;
    float *rcvrPtr;

	rcvr = stackObjectValue(0);
	if (failed()) {
		return null;
	}
	success(isWords(rcvr));
	if (failed()) {
		return null;
	}
	length = stSizeOf(rcvr);
	success(1);
	rcvrPtr = ((float *) (firstIndexableField(rcvr)));
	len = 0.0;
	for (i = 0; i <= (length - 1); i += 1) {
		len += (((double) (rcvrPtr[i]))) * (((double) (rcvrPtr[i])));
	}
	success(len > 0.0);
	if (failed()) {
		return null;
	}
	len = sqrt(len);
	for (i = 0; i <= (length - 1); i += 1) {
		rcvrPtr[i] = ((((double) (rcvrPtr[i]))) / len);
	}
}
primitiveLength(void)
{
	// FloatArrayPlugin>>#primitiveLength
    sqInt i;
    sqInt length;
    sqInt rcvr;
    float *rcvrPtr;
    double  result;

	rcvr = stackObjectValue(0);
	if (failed()) {
		return null;
	}
	success(isWords(rcvr));
	if (failed()) {
		return null;
	}
	length = stSizeOf(rcvr);
	success(1);
	rcvrPtr = ((float *) (firstIndexableField(rcvr)));
	result = 0.0;
	for (i = 0; i <= (length - 1); i += 1) {
		result += (((double) (rcvrPtr[i]))) * (((double) (rcvrPtr[i])));
	}
	result = sqrt(result);
	popthenPush(1, floatObjectOf(result));
}
primitiveHashArray(void)
{
	// FloatArrayPlugin>>#primitiveHashArray
    sqInt i;
    sqInt length;
    sqInt rcvr;
    int *rcvrPtr;
    sqInt result;

	rcvr = stackObjectValue(0);
	if (failed()) {
		return null;
	}
	success(isWords(rcvr));
	if (failed()) {
		return null;
	}
	length = stSizeOf(rcvr);
	rcvrPtr = ((int *) (firstIndexableField(rcvr)));
	result = 0;
	for (i = 0; i <= (length - 1); i += 1) {
		result += rcvrPtr[i];
	}
	pop(1);
	return pushInteger(result & 536870911);
}
示例#14
0
primitiveNormalize(void)
{
    sqInt i;
    double len;
    sqInt length;
    sqInt rcvr;
    float *rcvrPtr;

	rcvr = stackValue(0);
	if (!(isWords(rcvr))) {
		primitiveFailFor(PrimErrBadReceiver);
	}
	length = stSizeOf(rcvr);
	rcvrPtr = ((float *) (firstIndexableField(rcvr)));
	len = 0.0;
	for (i = 0; i < length; i += 1) {
		len += (((double) (rcvrPtr[i]))) * (((double) (rcvrPtr[i])));
	}
	if (!(len > 0.0)) {
		primitiveFailFor(PrimErrBadReceiver);
	}
	len = sqrt(len);
	for (i = 0; i < length; i += 1) {
		rcvrPtr[i] = ((((double) (rcvrPtr[i]))) / len);
	}
	return 0;
}
primitiveDivFloatArray(void)
{
	// FloatArrayPlugin>>#primitiveDivFloatArray
    sqInt arg;
    float *argPtr;
    sqInt i;
    sqInt length;
    sqInt rcvr;
    float *rcvrPtr;

	arg = stackObjectValue(0);
	rcvr = stackObjectValue(1);
	if (failed()) {
		return null;
	}
	success(isWords(arg));
	success(isWords(rcvr));
	if (failed()) {
		return null;
	}
	length = stSizeOf(arg);
	success(length == (stSizeOf(rcvr)));
	if (failed()) {
		return null;
	}
	rcvrPtr = ((float *) (firstIndexableField(rcvr)));

	/* Check if any of the argument's values is zero */

argPtr = ((float *) (firstIndexableField(arg)));
	for (i = 0; i <= (length - 1); i += 1) {
		if ((intAtPointer(((char*) (argPtr + i)))) == 0) {
			return primitiveFail();
		}
	}
	for (i = 0; i <= (length - 1); i += 1) {
		rcvrPtr[i] = ((((double) (rcvrPtr[i]))) / (((double) (argPtr[i]))));
	}
	pop(1);
}
示例#16
0
primitiveSubFloatArray(void)
{
    sqInt arg;
    float *argPtr;
    sqInt i;
    sqInt length;
    sqInt rcvr;
    float *rcvrPtr;

	arg = stackValue(0);
	rcvr = stackValue(1);
	if (!((isWords(arg))
		 && ((isWords(rcvr))
		 && (((length = stSizeOf(arg))) == (stSizeOf(rcvr)))))) {
		return primitiveFail();
	}
	rcvrPtr = ((float *) (firstIndexableField(rcvr)));
	argPtr = ((float *) (firstIndexableField(arg)));
	for (i = 0; i < length; i += 1) {
		rcvrPtr[i] = ((((double) (rcvrPtr[i]))) - (((double) (argPtr[i]))));
	}
	pop(1);
	return 0;
}
示例#17
0
primitiveSum(void)
{
    sqInt i;
    sqInt length;
    sqInt rcvr;
    float *rcvrPtr;
    double sum;

	rcvr = stackValue(0);
	if (!(isWords(rcvr))) {
		return primitiveFail();
	}
	length = stSizeOf(rcvr);
	rcvrPtr = ((float *) (firstIndexableField(rcvr)));
	sum = 0.0;
	for (i = 0; i < length; i += 1) {
		sum += ((double) (rcvrPtr[i]));
	}
	popthenPush(1, floatObjectOf(sum));
	return 0;
}
示例#18
0
primitiveHashArray(void)
{
    sqInt i;
    sqInt length;
    sqInt rcvr;
    int *rcvrPtr;
    sqInt result;

	rcvr = stackValue(0);
	if (!(isWords(rcvr))) {
		return primitiveFail();
	}
	length = stSizeOf(rcvr);
	rcvrPtr = ((int *) (firstIndexableField(rcvr)));
	result = 0;
	for (i = 0; i < length; i += 1) {
		result += rcvrPtr[i];
	}
	pop(1);
	return pushInteger(result & 0x1FFFFFFF);
}