FloatArray.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 19 Oct 2016 09:22:53 +0100
branchjv
changeset 23071 77ad9497363c
parent 20344 152b525b5c63
child 21089 d50f93ca9622
permissions -rw-r--r--
Issue #94 [3/x]: Respect `SYS_PROCESS_ID` when creating an initial system process rather than assigning it (hardcoded) value of zero.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20300
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
     1
"{ Encoding: utf8 }"
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
     2
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     3
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
 COPYRIGHT (c) 1993 by Claus Gittinger
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
     5
              All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    13
"
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    14
"{ Package: 'stx:libbasic' }"
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    15
18577
72ff8078cb76 class: FloatArray
Stefan Vogel <sv@exept.de>
parents: 17198
diff changeset
    16
"{ NameSpace: Smalltalk }"
72ff8078cb76 class: FloatArray
Stefan Vogel <sv@exept.de>
parents: 17198
diff changeset
    17
13826
ec58f3b538e5 class definition
Claus Gittinger <cg@exept.de>
parents: 13775
diff changeset
    18
AbstractNumberVector variableFloatSubclass:#FloatArray
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    19
        instanceVariableNames:''
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    20
        classVariableNames:''
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    21
        poolDictionaries:''
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    22
        category:'Collections-Arrayed'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    23
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    24
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    25
!FloatArray class methodsFor:'documentation'!
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    26
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    27
copyright
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    28
"
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    29
 COPYRIGHT (c) 1993 by Claus Gittinger
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    30
              All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    31
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    32
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    33
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    35
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    36
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    37
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    38
"
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    39
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    40
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    41
documentation
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    42
"
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    43
    FloatArrays store floats (and nothing else).
16638
45cb03e85f6a class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 15935
diff changeset
    44
    They have been added to support heavy duty number crunching and
19003
6ac2cb393fd7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 18577
diff changeset
    45
    data exchange with openGL frameworks and other mass data libraries.
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    46
    See documentation in DoubleArray for more information.
1263
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
    47
4062
4959de96b06f documentation
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
    48
    [memory requirements:]
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    49
        OBJ-HEADER + (size * float-size)
4062
4959de96b06f documentation
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
    50
1263
92c1db6b0776 commentary
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
    51
    [See also:]
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    52
        DoubleArray Array
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1263
diff changeset
    53
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1263
diff changeset
    54
    [author:]
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    55
        Claus Gittinger
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
    56
"
628
7aa563e4c64a version at the end
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
    57
! !
7aa563e4c64a version at the end
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
    58
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    59
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    60
13707
a8f395adfac2 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 12577
diff changeset
    61
!FloatArray class methodsFor:'queries'!
a8f395adfac2 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 12577
diff changeset
    62
a8f395adfac2 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 12577
diff changeset
    63
elementByteSize
16849
c20bd756c33b class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16638
diff changeset
    64
    "for bit-like containers, return the number of bytes stored per element.
c20bd756c33b class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16638
diff changeset
    65
     Here, 4 is returned"
c20bd756c33b class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16638
diff changeset
    66
13707
a8f395adfac2 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 12577
diff changeset
    67
    ^ 4
a8f395adfac2 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 12577
diff changeset
    68
a8f395adfac2 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 12577
diff changeset
    69
    "Created: / 15-09-2011 / 14:12:39 / cg"
a8f395adfac2 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 12577
diff changeset
    70
! !
a8f395adfac2 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 12577
diff changeset
    71
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    72
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    73
!FloatArray methodsFor:'copying'!
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    74
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    75
clone
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    76
    "return a copy of the receiver"
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    77
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    78
    |newArr|
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    79
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    80
    newArr := self class new:(self size).
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    81
%{
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 7220
diff changeset
    82
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    83
        INT _sz = __floatArraySize(self);
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    84
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    85
        bcopy(__FloatArrayInstPtr(self)->f_element,
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    86
              __FloatArrayInstPtr(newArr)->f_element,
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    87
              sizeof(float) * _sz);
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    88
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
    89
        RETURN (newArr);
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    90
    }
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    91
%}.
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    92
    newArr replaceFrom:1 to:self size with:self startingAt:1.
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    93
    ^ newArr
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    94
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    95
    "
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    96
     |f1 f2|
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    97
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    98
     f1 := FloatArray withAll:#(1 2 3 4 5).
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
    99
     f1 clone
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   100
    "
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   101
!
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   102
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   103
copyFrom:start to:stop
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   104
    "return a partial copy of the receiver"
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   105
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   106
%{
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 7220
diff changeset
   107
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   108
        if (__bothSmallInteger(start, stop)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   109
            INT __start = __intVal(start) - 1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   110
            INT __stop = __intVal(stop) - 1 ;
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   111
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   112
            if (__stop >= __start) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   113
                INT __sz = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   114
                // printf("o_size=%d floatArraySize=%d\n", __qSize(self), __sz);
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   115
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   116
                if (((unsigned INT)__start < __sz)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   117
                 && ((unsigned INT)__stop < __sz)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   118
                    INT __n = __stop - __start + 1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   119
                    OBJ __nObj;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   120
                    int nBytes;
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   121
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   122
                    // don't do this; sizeof returns the padded size!
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   123
                    // nBytes = sizeof(struct __FloatArray) + (__n - 1) * sizeof(float);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   124
                    nBytes = OHDR_SIZE + (__n * sizeof(float));
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
   125
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   126
                    // printf("__n=%d nBytes=%d\n", __n, nBytes);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   127
                    __nObj = __STX___new(nBytes);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   128
                    if (__nObj != nil) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   129
                        __objPtr(__nObj)->o_class = __qClass(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   130
                        __STORE(__nObj, __qClass(self));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   131
                        bcopy(__FloatArrayInstPtr(self)->f_element + __start,
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   132
                              __FloatArrayInstPtr(__nObj)->f_element,
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   133
                              sizeof(float) * __n);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   134
                        RETURN(__nObj);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   135
                    }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   136
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   137
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   138
        }
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   139
    }
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   140
%}.
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   141
    ^ super copyFrom:start to:stop
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   142
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   143
    "
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   144
     |f1 f2|
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   145
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   146
     f1 := FloatArray withAll:#(1 2 3 4 5 6).
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   147
     f2 := f1 copyFrom:2 to:4.
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   148
     f2
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   149
    "
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   150
!
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   151
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   152
replaceFrom:start to:stop with:aCollection startingAt:replStart
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   153
%{
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 7220
diff changeset
   154
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   155
         && __isFloats(aCollection)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   156
         && (__ClassInstPtr(__qClass(aCollection))->c_ninstvars == __mkSmallInteger(0))
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   157
         && __bothSmallInteger(start, stop)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   158
         && __isSmallInteger(replStart)
18577
72ff8078cb76 class: FloatArray
Stefan Vogel <sv@exept.de>
parents: 17198
diff changeset
   159
    ) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   160
        INT __start = __intVal(start) - 1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   161
        INT __stop = __intVal(stop) - 1 ;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   162
        INT __replStart = __intVal(replStart) - 1 ;
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   163
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   164
        if (__stop >= __start) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   165
            INT __sz = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   166
            INT __otherSz = __floatArraySize(aCollection);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   167
            INT __replStop = __replStart + (__stop-__start);
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   168
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   169
            if (((unsigned INT)__start < __sz)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   170
             && ((unsigned INT)__stop < __sz)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   171
             && ((unsigned INT)__replStart < __otherSz)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   172
             && ((unsigned INT)__replStop < __otherSz)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   173
                INT __n = __stop - __start + 1;
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   174
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   175
                if (aCollection == self) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   176
                    memmove(&(__FloatArrayInstPtr(self)->f_element[__start]),
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   177
                            &(__FloatArrayInstPtr(aCollection)->f_element[__replStart]),
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   178
                            sizeof(float) * __n);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   179
                } else {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   180
                    memcpy(&(__FloatArrayInstPtr(self)->f_element[__start]),
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   181
                           &(__FloatArrayInstPtr(aCollection)->f_element[__replStart]),
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   182
                           sizeof(float) * __n);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   183
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   184
                RETURN(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   185
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   186
        }
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   187
    }
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   188
%}.
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   189
    ^ super replaceFrom:start to:stop with:aCollection startingAt:replStart
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   190
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   191
    "
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   192
     |f1 f2|
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   193
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   194
     f1 := (1 to:5) asFloatArray.
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   195
     f2 := #(10 9 8 7 6) asFloatArray.
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   196
     f1 replaceFrom:1 to:3 with:f2 startingAt:3
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   197
    "
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   198
! !
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   199
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   200
!FloatArray methodsFor:'destructive arithmetic support'!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   201
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   202
primAbs
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   203
    "destructive absolute value of each element"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   204
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   205
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   206
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   207
        INT _sz = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   208
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   209
        float *_p = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   210
        float prev_p;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   211
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   212
        if (_sz > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   213
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   214
            prev_p = _p[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   215
            for (i=1; i<_sz; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   216
                float next_p = _p[i];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   217
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   218
                if (prev_p < 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   219
                    _p[i-1] = -prev_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   220
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   221
                prev_p = next_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   222
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   223
            if (prev_p < 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   224
                _p[i-1] = -prev_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   225
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   226
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   227
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   228
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   229
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   230
    super primAbs
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   231
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   232
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   233
     |f|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   234
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   235
     f := FloatArray withAll:#(-1 2 -3 4 -5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   236
     f abs.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   237
     f
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   238
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   239
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   240
    "Created: / 30-05-2007 / 17:50:17 / cg"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   241
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   242
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   243
primAddArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   244
    "add the vector argument into the receiver (destructive).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   245
     The argument must be another vector"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   246
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   247
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   248
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   249
     && __isFloats(floatArray)
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   250
     && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   251
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   252
        INT _sz2 = __floatArraySize(floatArray);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   253
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   254
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   255
        float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   256
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   257
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   258
            if (_sz2 >= _sz1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   259
                /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   260
                float prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   261
                float prev_p2 = _p2[0];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   262
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   263
                for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   264
                    float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   265
                    float next_p2 = _p2[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   266
                    _p1[i-1] = prev_p1 + prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   267
                    prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   268
                    prev_p2 = next_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   269
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   270
                _p1[i-1] = prev_p1 + prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   271
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   272
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   273
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   274
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   275
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   276
    super primAddArray:floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   277
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   278
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   279
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   280
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   281
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   282
     f2 := FloatArray withAll:#(2 2 2 3 3).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   283
     f1 += f2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   284
     f1
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   285
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   286
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   287
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   288
primAddScalar: aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   289
    "add the scalar argument into the receiver (destructive)."
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   290
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   291
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   292
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   293
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   294
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   295
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   296
        float v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   297
        float prev_p1;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   298
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   299
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   300
            if (__isFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   301
                v = (float)(__floatVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   302
            } else  if (__isShortFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   303
                v = __shortFloatVal(aScalar);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   304
            } else if (__isSmallInteger(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   305
                v = (float)(__intVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   306
            } else
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   307
                goto badArg;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   308
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   309
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   310
            prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   311
            for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   312
                float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   313
                _p1[i-1] = prev_p1 + v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   314
                prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   315
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   316
            _p1[i-1] = prev_p1 + v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   317
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   318
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   319
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   320
    badArg: ;
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   321
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   322
    super primAddScalar:aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   323
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   324
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   325
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   326
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   327
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   328
     f1 += 2.0.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   329
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   330
     f1 += 2.0 asShortFloat.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   331
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   332
     f1 += 2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   333
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   334
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   335
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   336
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   337
primDivArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   338
    "divide the vector argument into the receiver (destructive).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   339
     The argument must be another vector"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   340
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   341
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   342
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   343
     && __isFloats(floatArray)
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   344
     && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   345
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   346
        INT _sz2 = __floatArraySize(floatArray);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   347
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   348
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   349
        float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   350
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   351
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   352
            if (_sz2 >= _sz1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   353
                /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   354
                float prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   355
                float prev_p2 = _p2[0];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   356
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   357
                for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   358
                    float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   359
                    float next_p2 = _p2[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   360
                    _p1[i-1] = prev_p1 / prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   361
                    prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   362
                    prev_p2 = next_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   363
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   364
                _p1[i-1] = prev_p1 / prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   365
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   366
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   367
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   368
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   369
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   370
    super primDivArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   371
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   372
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   373
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   374
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   375
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   376
     f2 := FloatArray withAll:#(2 2 2 3 3).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   377
     f1 /= f2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   378
     f1
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   379
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   380
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   381
    "Modified: / 29-05-2007 / 16:01:34 / cg"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   382
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   383
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   384
primDivScalar: aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   385
    "divide the scalar argument into the receiver (destructive)."
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   386
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   387
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   388
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   389
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   390
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   391
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   392
        float v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   393
        float prev_p1;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   394
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   395
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   396
            if (__isFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   397
                v = (float)(__floatVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   398
            } else  if (__isShortFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   399
                v = __shortFloatVal(aScalar);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   400
            } else if (__isSmallInteger(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   401
                v = (float)(__intVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   402
            } else
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   403
                goto badArg;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   404
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   405
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   406
            prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   407
            for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   408
                float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   409
                _p1[i-1] = prev_p1 / v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   410
                prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   411
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   412
            _p1[i-1] = prev_p1 / v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   413
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   414
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   415
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   416
    badArg: ;
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   417
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   418
    super primDivScalar:aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   419
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   420
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   421
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   422
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   423
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   424
     f1 /= 2.0.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   425
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   426
     f1 /= 2.0 asShortFloat.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   427
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   428
     f1 /= 2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   429
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   430
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   431
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   432
    "Modified: / 29-05-2007 / 16:01:39 / cg"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   433
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   434
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   435
primMulArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   436
    "multiply the vector argument into the receiver (destructive).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   437
     The argument must be another vector"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   438
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   439
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   440
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   441
     && __isFloats(floatArray)
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   442
     && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   443
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   444
        INT _sz2 = __floatArraySize(floatArray);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   445
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   446
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   447
        float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   448
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   449
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   450
            if (_sz2 >= _sz1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   451
                float prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   452
                float prev_p2 = _p2[0];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   453
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   454
                for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   455
                    float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   456
                    float next_p2 = _p2[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   457
                    _p1[i-1] = prev_p1 * prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   458
                    prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   459
                    prev_p2 = next_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   460
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   461
                _p1[i-1] = prev_p1 * prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   462
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   463
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   464
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   465
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   466
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   467
    super primMulArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   468
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   469
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   470
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   471
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   472
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   473
     f2 := FloatArray withAll:#(2 2 2 3 3).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   474
     f1 *= f2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   475
     f1
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   476
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   477
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   478
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   479
primMulScalar: aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   480
    "multiply the scalar argument into the receiver (destructive)."
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   481
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   482
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   483
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   484
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   485
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   486
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   487
        float v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   488
        float prev_p1;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   489
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   490
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   491
            if (__isFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   492
                v = (float)(__floatVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   493
            } else  if (__isShortFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   494
                v = __shortFloatVal(aScalar);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   495
            } else if (__isSmallInteger(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   496
                v = (float)(__intVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   497
            } else
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   498
                goto badArg;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   499
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   500
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   501
            prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   502
            for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   503
                float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   504
                _p1[i-1] = prev_p1 * v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   505
                prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   506
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   507
            _p1[i-1] = prev_p1 * v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   508
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   509
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   510
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   511
    badArg: ;
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   512
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   513
    super primMulScalar:aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   514
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   515
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   516
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   517
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   518
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   519
     f1 *= 2.0.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   520
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   521
     f1 *= 2.0 asShortFloat.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   522
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   523
     f1 *= 2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   524
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   525
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   526
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   527
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   528
primNegated
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   529
    "destructive negative value of each element"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   530
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   531
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   532
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   533
        INT _sz = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   534
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   535
        float *_p = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   536
        float prev_p;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   537
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   538
        if (_sz > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   539
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   540
            prev_p = _p[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   541
            for (i=1; i<_sz; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   542
                float next_p = _p[i];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   543
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   544
                _p[i-1] = -prev_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   545
                prev_p = next_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   546
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   547
            _p[i-1] = -prev_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   548
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   549
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   550
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   551
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   552
    super primNegated
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   553
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   554
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   555
     |f|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   556
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   557
     f := FloatArray withAll:#(-1 2 -3 4 -5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   558
     f negated.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   559
     f
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   560
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   561
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   562
    "Created: / 30-05-2007 / 17:51:29 / cg"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   563
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   564
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   565
primSubtractArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   566
    "subtract the vector argument from the receiver (destructive).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   567
     The argument must be another vector"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   568
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   569
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   570
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   571
     && __isFloats(floatArray)
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   572
     && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   573
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   574
        INT _sz2 = __floatArraySize(floatArray);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   575
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   576
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   577
        float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   578
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   579
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   580
            if (_sz2 >= _sz1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   581
                float prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   582
                float prev_p2 = _p2[0];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   583
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   584
                for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   585
                    float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   586
                    float next_p2 = _p2[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   587
                    _p1[i-1] = prev_p1 - prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   588
                    prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   589
                    prev_p2 = next_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   590
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   591
                _p1[i-1] = prev_p1 - prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   592
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   593
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   594
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   595
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   596
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   597
    super primSubtractArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   598
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   599
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   600
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   601
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   602
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   603
     f2 := FloatArray withAll:#(2 2 2 3 3).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   604
     f1 -= f2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   605
     f1
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   606
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   607
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   608
    "Created: / 30-05-2007 / 17:42:41 / cg"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   609
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   610
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   611
primSubtractScalar: aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   612
    "subtract the scalar argument from the receiver (destructive)."
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   613
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   614
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   615
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   616
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   617
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   618
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   619
        float v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   620
        float prev_p1;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   621
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   622
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   623
            if (__isFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   624
                v = (float)(__floatVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   625
            } else  if (__isShortFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   626
                v = __shortFloatVal(aScalar);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   627
            } else if (__isSmallInteger(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   628
                v = (float)(__intVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   629
            } else
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   630
                goto badArg;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   631
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   632
            /* how about inline-mmx-asm for this... ? */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   633
            prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   634
            for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   635
                float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   636
                _p1[i-1] = prev_p1 - v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   637
                prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   638
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   639
            _p1[i-1] = prev_p1 - v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   640
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   641
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   642
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   643
    badArg: ;
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   644
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   645
    super primSubtractScalar:aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   646
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   647
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   648
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   649
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   650
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   651
     f1 -= 2.0.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   652
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   653
     f1 -= 2.0 asShortFloat.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   654
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   655
     f1 -= 2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   656
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   657
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   658
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   659
    "Created: / 30-05-2007 / 17:43:06 / cg"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   660
! !
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   661
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   662
!FloatArray methodsFor:'queries'!
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   663
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   664
defaultElement
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   665
    ^ ShortFloat zero
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   666
!
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   667
20300
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   668
isValidElement:anObject
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   669
    "return true, if I can hold this kind of object"
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   670
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   671
    ^ anObject isNumber
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   672
!
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   673
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   674
minMax
11212
8a6590cc1f4a comments
Claus Gittinger <cg@exept.de>
parents: 10580
diff changeset
   675
    "return a Tuple holding the smallest and largest element;
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   676
     redefined for speed"
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   677
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   678
    |min max empty|
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   679
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   680
%{
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 7220
diff changeset
   681
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   682
        INT _sz = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   683
        
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   684
        if (_sz > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   685
            INT _i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   686
            float *_p = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   687
            float _min, _max;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   688
            OBJ retVal;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   689
            
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   690
            _min = _max = _p[0];
13774
f36d336cc5c0 changed: #minMax
Claus Gittinger <cg@exept.de>
parents: 13707
diff changeset
   691
#ifdef PRE_4_OCT_2011
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   692
            if (_sz > 1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   693
                float _this = _p[1];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   694
                float _prev;
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   695
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   696
                /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   697
                for (_i=2; _i<_sz; _i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   698
                    _prev = _this;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   699
                    _this = _p[_i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   700
                    if (_prev < _min) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   701
                        _min = _prev;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   702
                    } else if (_prev > _max) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   703
                        _max = _prev;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   704
                    }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   705
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   706
                if (_this < _min) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   707
                    _min = _this;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   708
                } else if (_this > _max) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   709
                    _max = _this;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   710
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   711
            }
13774
f36d336cc5c0 changed: #minMax
Claus Gittinger <cg@exept.de>
parents: 13707
diff changeset
   712
#else
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   713
            for (_i=_sz-1; _i>0; _i-=2) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   714
                float _v1 = _p[_i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   715
                float _v2 = _p[_i-1];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   716
                if (_v1 < _v2) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   717
                    if (_v1 < _min) _min = _v1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   718
                    if (_v2 > _max) _max = _v2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   719
                } else {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   720
                    if (_v2 < _min) _min = _v2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   721
                    if (_v1 > _max) _max = _v1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   722
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   723
            }
13774
f36d336cc5c0 changed: #minMax
Claus Gittinger <cg@exept.de>
parents: 13707
diff changeset
   724
#endif
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   725
            min = __MKFLOAT(_min);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   726
            __PROTECT__(min);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   727
            max = __MKFLOAT(_max);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   728
            __UNPROTECT__(min);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   729
            RETURN (__ARRAY_WITH2(min, max));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   730
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   731
        empty = true;
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   732
    }
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   733
%}.
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   734
    empty == true ifTrue:[
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   735
        ^ self emptyCollectionError.
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   736
    ].
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   737
    ^ Array with:(super min) with:(super max)
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   738
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   739
    "
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   740
     |f1|
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   741
13774
f36d336cc5c0 changed: #minMax
Claus Gittinger <cg@exept.de>
parents: 13707
diff changeset
   742
     f1 := (1 to:10000) asFloatArray.
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   743
     Time millisecondsToRun:[ 1000 timesRepeat:[ f1 minMax ] ]
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   744
    "
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   745
    "
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   746
     |f1|
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   747
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   748
     f1 := FloatArray withAll:#(1 2 3 4 5).
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   749
     f1 minMax
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   750
    "
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   751
    "
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   752
     |f1|
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   753
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   754
     f1 := FloatArray withAll:#(1 2 3 4).
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   755
     f1 minMax
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   756
    "
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   757
    "
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   758
     |f1|
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   759
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   760
     f1 := FloatArray withAll:#(5 4 3 2 1).
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   761
     f1 minMax
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   762
    "
13774
f36d336cc5c0 changed: #minMax
Claus Gittinger <cg@exept.de>
parents: 13707
diff changeset
   763
f36d336cc5c0 changed: #minMax
Claus Gittinger <cg@exept.de>
parents: 13707
diff changeset
   764
    "Modified (comment): / 07-10-2011 / 13:03:30 / cg"
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   765
!
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   766
12577
a3224998ea6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11212
diff changeset
   767
numFloats
a3224998ea6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11212
diff changeset
   768
    ^ self size
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   769
! !
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   770
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   771
!FloatArray methodsFor:'vector arithmetic'!
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   772
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   773
dot: aFloatVector
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   774
    "Return the dot product of the receiver and the argument.
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   775
     Raises an error, if the argument is not of the same size as the receiver."
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   776
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   777
    | mySize result |
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   778
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   779
"/    <primitive:'primitiveDotProduct' module: 'FloatArrayPlugin'>
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   780
%{
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   781
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   782
     && (__ClassInstPtr(__qClass(aFloatVector))->c_ninstvars == __mkSmallInteger(0))) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   783
        INT __mySize = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   784
        double __result = 0.0;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   785
        float *__p1 = __FloatArrayInstPtr(self)->f_element;
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   786
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   787
        if (__mySize > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   788
            if (__isFloats(aFloatVector)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   789
                INT __otherSize = __floatArraySize(aFloatVector);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   790
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   791
                if (__mySize == __otherSize) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   792
                    float *__p2 = __FloatArrayInstPtr(aFloatVector)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   793
                    INT __i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   794
                    /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   795
                    for (__i=0; __i<__mySize; __i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   796
                        __result += (__p1[__i] * __p2[__i]);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   797
                    }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   798
                    RETURN (__MKFLOAT(__result));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   799
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   800
            } else if (__isDoubles(aFloatVector)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   801
                INT __otherSize = __doubleArraySize(aFloatVector);
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   802
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   803
                if (__mySize == __otherSize) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   804
                    double *__p2 = __DoubleArrayInstPtr(aFloatVector)->d_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   805
                    INT __i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   806
                    /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   807
                    for (__i=0; __i<__mySize; __i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   808
                        __result += (__p1[__i] * __p2[__i]);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   809
                    }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   810
                    RETURN (__MKFLOAT(__result));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   811
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   812
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   813
        }
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   814
    }
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   815
%}.
15935
35582e2e065c class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 14692
diff changeset
   816
    ^ super dot:aFloatVector
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   817
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   818
    "
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   819
     |v|
11212
8a6590cc1f4a comments
Claus Gittinger <cg@exept.de>
parents: 10580
diff changeset
   820
     v := #(2.0 2.0 1.0) asFloatArray.
19003
6ac2cb393fd7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 18577
diff changeset
   821
     v dot:v.
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   822
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   823
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   824
     v := #(2.0 2.0 1.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   825
     v dot:v.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   826
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   827
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   828
     v := #(2.0 2.0 1.0).
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   829
     v dot:v.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   830
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   831
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   832
     v1 := #(2.0 2.0 1.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   833
     v2 := #(2.0 2.0 1.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   834
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   835
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   836
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   837
     v1 := #(2.0 2.0 1.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   838
     v2 := #(2.0 2.0 1.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   839
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   840
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   841
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   842
     v1 := #(2.0 2.0 1.0).
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   843
     v2 := #(2.0 2.0 1.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   844
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   845
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   846
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   847
     v1 := #(2.0 2.0 1.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   848
     v2 := #(2.0 2.0 1.0).
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   849
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   850
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   851
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   852
     v1 := #(2.0 2.0 1.0).
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   853
     v2 := #(2.0 2.0 1.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   854
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   855
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   856
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   857
     v1 := #(2.0 2.0 1.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   858
     v2 := #(2.0 2.0 1.0).
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   859
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   860
    "
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
   861
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   862
    "
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   863
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   864
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   865
     v1 := Array new:10000 withAll:2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   866
     v2 := Array new:10000 withAll:3.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   867
     Time millisecondsToRun:[
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   868
        10000 timesRepeat:[
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   869
          v1 dot:v2.
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   870
        ]
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   871
     ]
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   872
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   873
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   874
     |v1 v2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   875
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   876
     v1 := FloatArray new:10000 withAll:2.
19003
6ac2cb393fd7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 18577
diff changeset
   877
     v2 := FloatArray new:10000 withAll:3.
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   878
     Time millisecondsToRun:[
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   879
        10000 timesRepeat:[
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   880
          v1 dot:v2.
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   881
        ]
19003
6ac2cb393fd7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 18577
diff changeset
   882
     ]
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   883
    "
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   884
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   885
    "
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   886
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   887
     v1 := #(2.0 2.0 1.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   888
     v2 := #(2.0 2.0 1.0 0.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   889
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   890
    "
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   891
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
   892
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   893
    "Created: / 29-05-2007 / 13:13:39 / cg"
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   894
!
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   895
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   896
hornerMultiplyAndAdd:x
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   897
    "primitive support for horner's-method computation of polynomials.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   898
     The vector is interpreted as providing the factors for a polynomial,
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   899
        an*x^n + (an-1)*x^(n-1) + ... + a2(x) + a1
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   900
     where the ai are the elements of the Array.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   901
     The highest rank factor is at the first position, the 0-rank constant at last.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   902
     This is inlined c-code, which may get compiled to fast machine code,
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   903
     using multiply-and-add or vector instructions, if the CPU/Compiler support them."
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   904
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   905
    | mySize result |
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   906
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   907
%{
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   908
    double __x;
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
   909
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   910
    if (__isFloat(x)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   911
        __x = __floatVal(x);
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   912
    } else if (__isShortFloat(x)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   913
        __x = (double)__shortFloatVal(x);
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   914
    } else if (__isSmallInteger(x)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   915
        __x = (double)(__intVal(x));
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   916
    } else {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   917
        goto getOutOfHere;
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   918
    }
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
   919
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   920
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   921
        INT __mySize = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   922
        float *__elements = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   923
        double __result = __elements[0];
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   924
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   925
        if (__mySize > 1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   926
            INT __i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   927
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   928
            for (__i=1; __i<__mySize; __i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   929
                __result = (__result * __x) + __elements[__i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   930
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   931
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   932
        RETURN (__MKFLOAT(__result));
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   933
    }
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
   934
getOutOfHere: ;
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   935
%}.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   936
    ^ super hornerMultiplyAndAdd:x
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   937
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   938
    "
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   939
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   940
     v := #(2.0 3.0 4.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   941
     v  hornerMultiplyAndAdd:10.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   942
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   943
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   944
     v := Array new:100 withAll:2.0.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   945
     v hornerMultiplyAndAdd:10
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   946
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   947
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   948
     v := FloatArray new:100 withAll:2.0.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   949
     v hornerMultiplyAndAdd:10
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   950
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   951
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   952
     v := Array new:100 withAll:2.0.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   953
     Time millisecondsToRun:[
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   954
        10000 timesRepeat:[ v hornerMultiplyAndAdd:10]
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   955
     ]
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   956
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   957
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   958
     v := FloatArray new:100 withAll:2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   959
     Time millisecondsToRun:[
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   960
        10000 timesRepeat:[ v hornerMultiplyAndAdd:10]
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   961
     ]
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   962
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   963
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   964
     v := DoubleArray new:100 withAll:2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   965
     Time millisecondsToRun:[
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   966
        10000 timesRepeat:[ v hornerMultiplyAndAdd:10]
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   967
     ]
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   968
    "
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   969
! !
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   970
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   971
628
7aa563e4c64a version at the end
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   972
!FloatArray class methodsFor:'documentation'!
603
72bdeb24ccba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   973
72bdeb24ccba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   974
version
18577
72ff8078cb76 class: FloatArray
Stefan Vogel <sv@exept.de>
parents: 17198
diff changeset
   975
    ^ '$Header$'
12577
a3224998ea6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11212
diff changeset
   976
!
a3224998ea6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11212
diff changeset
   977
a3224998ea6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11212
diff changeset
   978
version_CVS
18577
72ff8078cb76 class: FloatArray
Stefan Vogel <sv@exept.de>
parents: 17198
diff changeset
   979
    ^ '$Header$'
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
   980
! !
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   981