diff --git a/C/stdpreds.c b/C/stdpreds.c index 33fbbee88..e3478fabe 100644 --- a/C/stdpreds.c +++ b/C/stdpreds.c @@ -11,8 +11,12 @@ * File: stdpreds.c * * comments: General-purpose C implemented system predicates * * * -* Last rev: $Date: 2006-05-19 14:31:32 $,$Author: vsc $ * +* Last rev: $Date: 2006-06-05 19:36:00 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.104 2006/05/19 14:31:32 vsc +* get rid of IntArrays and FloatArray code. +* include holes when calculating memory usage. +* * Revision 1.103 2006/05/18 16:33:05 vsc * fix info reported by memory manager under DL_MALLOC and SYSTEM_MALLOC * @@ -2833,6 +2837,40 @@ p_loop(void) { } #endif +#if QSAR +static Int +p_in_range(void) { + Term t; + double i,j; + double d1; + double d2; + double d3; + + t = Deref(ARG1); + if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t); + t = Deref(ARG4); + if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t); + d1 = i-j; + t = Deref(ARG2); + if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t); + t = Deref(ARG5); + if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t); + d2 = i-j; + t = Deref(ARG3); + if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t); + t = Deref(ARG6); + if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t); + d3 = i-j; + t = Deref(ARG7); + if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t); + t = Deref(ARG8); + if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t); + + return fabs(sqrt(d1*d1 + d2*d2 + d3*d3)-i) <= j; + +} +#endif + static Int p_max_tagged_integer(void) { return Yap_unify(ARG1, MkIntTerm(MAX_ABS_INT-1L)); @@ -2952,6 +2990,9 @@ Yap_InitCPreds(void) Yap_InitCPred("euc_dist", 3, p_euc_dist, SafePredFlag); Yap_InitCPred("loop", 0, p_loop, SafePredFlag); #endif +#if QSAR + Yap_InitCPred("in_range", 8, p_in_range, SafePredFlag); +#endif #ifdef DEBUG Yap_InitCPred("dump_active_goals", 0, p_dump_active_goals, SafePredFlag|SyncPredFlag); #endif diff --git a/LGPL/JPL/src/jpl.c b/LGPL/JPL/src/jpl.c index 445233c44..8673be88f 100644 --- a/LGPL/JPL/src/jpl.c +++ b/LGPL/JPL/src/jpl.c @@ -1,4 +1,4 @@ -/* $Id: jpl.c,v 1.10 2006-05-19 13:48:11 vsc Exp $ +/* $Id: jpl.c,v 1.11 2006-06-05 19:36:00 vsc Exp $ Part of JPL -- SWI-Prolog/Java interface @@ -2201,6 +2201,35 @@ jni_SetByteArrayElement( } +/* + %T jni_SetByteArrayElement(+term, +term, +term) + */ +static foreign_t +jni_SetDoubleArrayElement( + term_t ta1, // +Arg1 + term_t ta2, // +Arg2 + term_t ta3 // +Arg3 + ) + { + jboolean r; // Prolog exit/fail outcome + jdoubleArray p1; + jint i2; + jdouble i3; + + if ( !jni_ensure_jvm() ) + { + return FALSE; + } + r = + JNI_term_to_double_jarray(env,ta1,&p1) + && JNI_term_to_jint(ta2,&i2) + && JNI_term_to_jdouble(ta3,&i3) + && ( (*env)->SetDoubleArrayRegion(env,p1,i2,1,&i3) , TRUE ); + + return jni_check_exception() && r; + + } + /* %T jni_void( +integer, +term, +term, +term) */ @@ -3902,6 +3931,7 @@ PL_extension predspecs[] = { "jni_func", 5, jni_func_3_plc, 0 }, { "jni_func", 6, jni_func_4_plc, 0 }, { "jni_SetByteArrayElement", 3, jni_SetByteArrayElement, 0 }, + { "jni_SetDoubleArrayElement", 3, jni_SetDoubleArrayElement, 0 }, { "jpl_c_lib_version", 1, jpl_c_lib_version_1_plc, 0 }, { "jpl_c_lib_version", 4, jpl_c_lib_version_4_plc, 0 }, { NULL, 0, NULL, 0 }