FloatArray.st
changeset 8913 b9498d27a554
parent 7220 5225d13b2d57
child 10561 6987bd25c09d
equal deleted inserted replaced
8912:3d1947a79cf3 8913:b9498d27a554
   128 primAddArray: floatArray
   128 primAddArray: floatArray
   129     "add the vector argument into the receiver (destructive).
   129     "add the vector argument into the receiver (destructive).
   130      The argument must be another vector"
   130      The argument must be another vector"
   131 
   131 
   132 %{
   132 %{
   133     if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0))
   133     if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
   134      && __isFloats(floatArray)
   134      && __isFloats(floatArray)
   135      && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __MKSMALLINT(0))) {
   135      && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
   136         int _sz1 = __floatArraySize(self);
   136         int _sz1 = __floatArraySize(self);
   137         int _sz2 = __floatArraySize(floatArray);
   137         int _sz2 = __floatArraySize(floatArray);
   138         int i;
   138         int i;
   139         float *_p1 = __FloatArrayInstPtr(self)->f_element;
   139         float *_p1 = __FloatArrayInstPtr(self)->f_element;
   140         float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
   140         float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
   162 
   162 
   163 primAddScalar: aScalar
   163 primAddScalar: aScalar
   164     "add the scalar argument into the receiver (destructive)."
   164     "add the scalar argument into the receiver (destructive)."
   165 
   165 
   166 %{
   166 %{
   167     if (__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0)) {
   167     if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
   168         int _sz1 = __floatArraySize(self);
   168         int _sz1 = __floatArraySize(self);
   169         int i;
   169         int i;
   170         float *_p1 = __FloatArrayInstPtr(self)->f_element;
   170         float *_p1 = __FloatArrayInstPtr(self)->f_element;
   171         float v;
   171         float v;
   172 
   172 
   205 primMulArray: floatArray
   205 primMulArray: floatArray
   206     "multiply the vector argument into the receiver (destructive).
   206     "multiply the vector argument into the receiver (destructive).
   207      The argument must be another vector"
   207      The argument must be another vector"
   208 
   208 
   209 %{
   209 %{
   210     if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0))
   210     if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
   211      && __isFloats(floatArray)
   211      && __isFloats(floatArray)
   212      && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __MKSMALLINT(0))) {
   212      && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
   213         int _sz1 = __floatArraySize(self);
   213         int _sz1 = __floatArraySize(self);
   214         int _sz2 = __floatArraySize(floatArray);
   214         int _sz2 = __floatArraySize(floatArray);
   215         int i;
   215         int i;
   216         float *_p1 = __FloatArrayInstPtr(self)->f_element;
   216         float *_p1 = __FloatArrayInstPtr(self)->f_element;
   217         float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
   217         float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
   239 
   239 
   240 primMulScalar: aScalar
   240 primMulScalar: aScalar
   241     "multiply the scalar argument into the receiver (destructive)."
   241     "multiply the scalar argument into the receiver (destructive)."
   242 
   242 
   243 %{
   243 %{
   244     if (__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0)) {
   244     if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
   245         int _sz1 = __floatArraySize(self);
   245         int _sz1 = __floatArraySize(self);
   246         int i;
   246         int i;
   247         float *_p1 = __FloatArrayInstPtr(self)->f_element;
   247         float *_p1 = __FloatArrayInstPtr(self)->f_element;
   248         float v;
   248         float v;
   249 
   249 
   286 
   286 
   287     |newArr|
   287     |newArr|
   288 
   288 
   289     newArr := self class new:(self size).
   289     newArr := self class new:(self size).
   290 %{
   290 %{
   291     if (__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0)) {
   291     if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
   292         int _sz = __floatArraySize(self);
   292         int _sz = __floatArraySize(self);
   293 
   293 
   294         bcopy(__FloatArrayInstPtr(self)->f_element,
   294         bcopy(__FloatArrayInstPtr(self)->f_element,
   295               __FloatArrayInstPtr(newArr)->f_element,
   295               __FloatArrayInstPtr(newArr)->f_element,
   296               sizeof(float) * _sz);
   296               sizeof(float) * _sz);
   311 
   311 
   312 copyFrom:start to:stop
   312 copyFrom:start to:stop
   313     "return a partial copy of the receiver"
   313     "return a partial copy of the receiver"
   314 
   314 
   315 %{
   315 %{
   316     if (__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0)) {
   316     if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
   317         if (__bothSmallInteger(start, stop)) {
   317         if (__bothSmallInteger(start, stop)) {
   318             int __start = __intVal(start) - 1;
   318             int __start = __intVal(start) - 1;
   319             int __stop = __intVal(stop) - 1 ;
   319             int __stop = __intVal(stop) - 1 ;
   320 
   320 
   321             if (__stop >= __start) {
   321             if (__stop >= __start) {
   351     "
   351     "
   352 !
   352 !
   353 
   353 
   354 replaceFrom:start to:stop with:aCollection startingAt:replStart
   354 replaceFrom:start to:stop with:aCollection startingAt:replStart
   355 %{
   355 %{
   356     if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0))
   356     if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
   357      && __isFloats(aCollection)
   357      && __isFloats(aCollection)
   358      && (__ClassInstPtr(__qClass(aCollection))->c_ninstvars == __MKSMALLINT(0))) {
   358      && (__ClassInstPtr(__qClass(aCollection))->c_ninstvars == __mkSmallInteger(0))) {
   359         if (__bothSmallInteger(start, stop)
   359         if (__bothSmallInteger(start, stop)
   360          && __isSmallInteger(replStart)) {
   360          && __isSmallInteger(replStart)) {
   361             int __start = __intVal(start) - 1;
   361             int __start = __intVal(start) - 1;
   362             int __stop = __intVal(stop) - 1 ;
   362             int __stop = __intVal(stop) - 1 ;
   363             int __replStart = __intVal(replStart) - 1 ;
   363             int __replStart = __intVal(replStart) - 1 ;
   449 
   449 
   450 max
   450 max
   451     "return the largest element;
   451     "return the largest element;
   452      redefined for speed"
   452      redefined for speed"
   453 %{
   453 %{
   454     if (__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0)) {
   454     if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
   455         int _sz = __floatArraySize(self);
   455         int _sz = __floatArraySize(self);
   456 
   456 
   457         if (_sz > 0) {
   457         if (_sz > 0) {
   458             float *_p = __FloatArrayInstPtr(self)->f_element;
   458             float *_p = __FloatArrayInstPtr(self)->f_element;
   459             float _max;
   459             float _max;
   500 
   500 
   501 min
   501 min
   502     "return the largest element;
   502     "return the largest element;
   503      redefined for speed"
   503      redefined for speed"
   504 %{
   504 %{
   505     if (__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0)) {
   505     if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
   506         int _sz = __floatArraySize(self);
   506         int _sz = __floatArraySize(self);
   507 
   507 
   508         if (_sz > 0) {
   508         if (_sz > 0) {
   509             float *_p = __FloatArrayInstPtr(self)->f_element;
   509             float *_p = __FloatArrayInstPtr(self)->f_element;
   510             float _min;
   510             float _min;
   554      redefined for speed"
   554      redefined for speed"
   555 
   555 
   556     |min max|
   556     |min max|
   557 
   557 
   558 %{
   558 %{
   559     if (__ClassInstPtr(__qClass(self))->c_ninstvars == __MKSMALLINT(0)) {
   559     if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
   560         int _sz = __floatArraySize(self);
   560         int _sz = __floatArraySize(self);
   561         if (_sz > 0) {
   561         if (_sz > 0) {
   562             int _i;
   562             int _i;
   563             float *_p = __FloatArrayInstPtr(self)->f_element;
   563             float *_p = __FloatArrayInstPtr(self)->f_element;
   564             float _min, _max;
   564             float _min, _max;
   614 ! !
   614 ! !
   615 
   615 
   616 !FloatArray class methodsFor:'documentation'!
   616 !FloatArray class methodsFor:'documentation'!
   617 
   617 
   618 version
   618 version
   619     ^ '$Header: /cvs/stx/stx/libbasic/FloatArray.st,v 1.19 2003-04-22 09:39:26 cg Exp $'
   619     ^ '$Header: /cvs/stx/stx/libbasic/FloatArray.st,v 1.20 2005-07-08 17:15:01 cg Exp $'
   620 ! !
   620 ! !