FloatArray.st
author Claus Gittinger <cg@exept.de>
Sun, 03 Mar 2019 00:26:13 +0100
changeset 23806 c2dcab4ec688
parent 23798 300f01ecb7f0
child 24306 ee7c9f895369
permissions -rw-r--r--
#REFACTORING by cg class: FloatArray class definition
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22257
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
     1
"{ Encoding: utf8 }"
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
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
23806
c2dcab4ec688 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23798
diff changeset
    18
UnboxedFloatArray variableFloatSubclass:#FloatArray
21081
7c7d1c059ce9 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 20313
diff changeset
    19
	instanceVariableNames:''
7c7d1c059ce9 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 20313
diff changeset
    20
	classVariableNames:''
7c7d1c059ce9 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 20313
diff changeset
    21
	poolDictionaries:''
7c7d1c059ce9 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 20313
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
23798
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
    59
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
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
23798
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
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
22263
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   122
                    // here we need to differ 32bit and 64bit
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   123
                    // because on 32bit machines we need to take care about the alignment
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   124
                    // but sadly, the same code is wrong for 64bit machines
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   125
                    if (__POINTER_SIZE__ == 8) {
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   126
                        nBytes = OHDR_SIZE + (__n * sizeof(float));
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   127
                    } else {
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   128
                        nBytes = sizeof(struct __FloatArray) + (__n - 1) * sizeof(float);
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   129
                    }
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
   130
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   131
                    // printf("__n=%d nBytes=%d\n", __n, nBytes);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   132
                    __nObj = __STX___new(nBytes);
22257
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   133
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   134
                    if (__nObj != nil) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   135
                        __objPtr(__nObj)->o_class = __qClass(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   136
                        __STORE(__nObj, __qClass(self));
22257
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   137
                        // bcopy is marked as deprecated
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   138
                        // bcopy(
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   139
                        //     __FloatArrayInstPtr(self)->f_element,   
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   140
                        //     __FloatArrayInstPtr(__nObj)->f_element + __start,  
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   141
                        //     __n * sizeof(float));
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   142
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   143
                        memcpy(
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   144
                            __FloatArrayInstPtr(__nObj)->f_element + __start,
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   145
                            __FloatArrayInstPtr(self)->f_element,
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   146
                            __n * sizeof(float));
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   147
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   148
                        RETURN(__nObj);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   149
                    }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   150
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   151
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   152
        }
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   153
    }
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   154
%}.
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   155
    ^ super copyFrom:start to:stop
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   156
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   157
    "
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   158
     |f1 f2|
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   159
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   160
     f1 := FloatArray withAll:#(1 2 3 4 5 6).
22257
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   161
     f2 := f1 copyFrom:1 to:3.
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   162
     f2                      
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   163
    "
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   164
!
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   165
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   166
replaceFrom:start to:stop with:aCollection startingAt:replStart
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   167
%{
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 7220
diff changeset
   168
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   169
         && __isFloats(aCollection)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   170
         && (__ClassInstPtr(__qClass(aCollection))->c_ninstvars == __mkSmallInteger(0))
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   171
         && __bothSmallInteger(start, stop)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   172
         && __isSmallInteger(replStart)
18577
72ff8078cb76 class: FloatArray
Stefan Vogel <sv@exept.de>
parents: 17198
diff changeset
   173
    ) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   174
        INT __start = __intVal(start) - 1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   175
        INT __stop = __intVal(stop) - 1 ;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   176
        INT __replStart = __intVal(replStart) - 1 ;
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   177
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   178
        if (__stop >= __start) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   179
            INT __sz = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   180
            INT __otherSz = __floatArraySize(aCollection);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   181
            INT __replStop = __replStart + (__stop-__start);
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   182
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   183
            if (((unsigned INT)__start < __sz)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   184
             && ((unsigned INT)__stop < __sz)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   185
             && ((unsigned INT)__replStart < __otherSz)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   186
             && ((unsigned INT)__replStop < __otherSz)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   187
                INT __n = __stop - __start + 1;
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   188
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   189
                if (aCollection == self) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   190
                    memmove(&(__FloatArrayInstPtr(self)->f_element[__start]),
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   191
                            &(__FloatArrayInstPtr(aCollection)->f_element[__replStart]),
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   192
                            sizeof(float) * __n);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   193
                } else {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   194
                    memcpy(&(__FloatArrayInstPtr(self)->f_element[__start]),
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   195
                           &(__FloatArrayInstPtr(aCollection)->f_element[__replStart]),
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   196
                           sizeof(float) * __n);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   197
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   198
                RETURN(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   199
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   200
        }
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   201
    }
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   202
%}.
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   203
    ^ super replaceFrom:start to:stop with:aCollection startingAt:replStart
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   204
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   205
    "
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   206
     |f1 f2|
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   207
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   208
     f1 := (1 to:5) asFloatArray.
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   209
     f2 := #(10 9 8 7 6) asFloatArray.
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   210
     f1 replaceFrom:1 to:3 with:f2 startingAt:3
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   211
    "
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   212
! !
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   213
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   214
!FloatArray methodsFor:'destructive arithmetic support'!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   215
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   216
primAbs
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   217
    "destructive absolute value of each element"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   218
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   219
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   220
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   221
        INT _sz = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   222
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   223
        float *_p = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   224
        float prev_p;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   225
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   226
        if (_sz > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   227
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   228
            prev_p = _p[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   229
            for (i=1; i<_sz; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   230
                float next_p = _p[i];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   231
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   232
                if (prev_p < 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   233
                    _p[i-1] = -prev_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   234
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   235
                prev_p = next_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   236
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   237
            if (prev_p < 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   238
                _p[i-1] = -prev_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   239
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   240
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   241
        RETURN (self);
17198
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
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   244
    super primAbs
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   245
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
     |f|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   248
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   249
     f := FloatArray withAll:#(-1 2 -3 4 -5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   250
     f abs.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   251
     f
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   252
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   253
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   254
    "Created: / 30-05-2007 / 17:50:17 / cg"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   255
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   256
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   257
primAddArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   258
    "add the vector argument into the receiver (destructive).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   259
     The argument must be another vector"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   260
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   261
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   262
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   263
     && __isFloats(floatArray)
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   264
     && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   265
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   266
        INT _sz2 = __floatArraySize(floatArray);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   267
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   268
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   269
        float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   270
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   271
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   272
            if (_sz2 >= _sz1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   273
                /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   274
                float prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   275
                float prev_p2 = _p2[0];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   276
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   277
                for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   278
                    float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   279
                    float next_p2 = _p2[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   280
                    _p1[i-1] = prev_p1 + prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   281
                    prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   282
                    prev_p2 = next_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   283
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   284
                _p1[i-1] = prev_p1 + prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   285
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   286
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   287
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   288
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   289
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   290
    super primAddArray:floatArray
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
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   293
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   294
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   295
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   296
     f2 := FloatArray withAll:#(2 2 2 3 3).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   297
     f1 += f2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   298
     f1
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   299
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   300
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   301
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   302
primAddScalar: aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   303
    "add the scalar argument into the receiver (destructive)."
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   304
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   305
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   306
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   307
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   308
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   309
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   310
        float v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   311
        float prev_p1;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   312
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   313
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   314
            if (__isFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   315
                v = (float)(__floatVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   316
            } else  if (__isShortFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   317
                v = __shortFloatVal(aScalar);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   318
            } else if (__isSmallInteger(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   319
                v = (float)(__intVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   320
            } else
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   321
                goto badArg;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   322
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   323
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   324
            prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   325
            for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   326
                float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   327
                _p1[i-1] = prev_p1 + v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   328
                prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   329
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   330
            _p1[i-1] = prev_p1 + v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   331
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   332
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   333
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   334
    badArg: ;
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
    super primAddScalar:aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   337
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   338
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   339
     |f1 f2|
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
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   342
     f1 += 2.0.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   343
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   344
     f1 += 2.0 asShortFloat.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   345
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   346
     f1 += 2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   347
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   348
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   349
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   350
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   351
primDivArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   352
    "divide the vector argument into the receiver (destructive).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   353
     The argument must be another vector"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   354
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   355
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   356
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   357
     && __isFloats(floatArray)
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   358
     && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   359
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   360
        INT _sz2 = __floatArraySize(floatArray);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   361
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   362
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   363
        float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   364
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   365
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   366
            if (_sz2 >= _sz1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   367
                /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   368
                float prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   369
                float prev_p2 = _p2[0];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   370
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   371
                for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   372
                    float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   373
                    float next_p2 = _p2[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   374
                    _p1[i-1] = prev_p1 / prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   375
                    prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   376
                    prev_p2 = next_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   377
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   378
                _p1[i-1] = prev_p1 / prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   379
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   380
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   381
        RETURN (self);
17198
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
    super primDivArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   385
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
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   388
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   389
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   390
     f2 := FloatArray withAll:#(2 2 2 3 3).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   391
     f1 /= f2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   392
     f1
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   393
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   394
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   395
    "Modified: / 29-05-2007 / 16:01:34 / cg"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   396
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   397
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   398
primDivScalar: aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   399
    "divide the scalar argument into the receiver (destructive)."
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   400
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   401
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   402
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   403
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   404
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   405
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   406
        float v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   407
        float prev_p1;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   408
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   409
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   410
            if (__isFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   411
                v = (float)(__floatVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   412
            } else  if (__isShortFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   413
                v = __shortFloatVal(aScalar);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   414
            } else if (__isSmallInteger(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   415
                v = (float)(__intVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   416
            } else
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   417
                goto badArg;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   418
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   419
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   420
            prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   421
            for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   422
                float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   423
                _p1[i-1] = prev_p1 / v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   424
                prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   425
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   426
            _p1[i-1] = prev_p1 / v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   427
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   428
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   429
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   430
    badArg: ;
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
    super primDivScalar:aScalar
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
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   436
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   437
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   438
     f1 /= 2.0.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   439
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   440
     f1 /= 2.0 asShortFloat.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   441
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   442
     f1 /= 2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   443
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   444
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   445
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   446
    "Modified: / 29-05-2007 / 16:01:39 / cg"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   447
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   448
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   449
primMulArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   450
    "multiply the vector argument into the receiver (destructive).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   451
     The argument must be another vector"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   452
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   453
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   454
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   455
     && __isFloats(floatArray)
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   456
     && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   457
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   458
        INT _sz2 = __floatArraySize(floatArray);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   459
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   460
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   461
        float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   462
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   463
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   464
            if (_sz2 >= _sz1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   465
                float prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   466
                float prev_p2 = _p2[0];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   467
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   468
                for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   469
                    float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   470
                    float next_p2 = _p2[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   471
                    _p1[i-1] = prev_p1 * prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   472
                    prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   473
                    prev_p2 = next_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   474
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   475
                _p1[i-1] = prev_p1 * prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   476
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   477
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   478
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   479
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   480
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   481
    super primMulArray: floatArray
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
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   484
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   485
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   486
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   487
     f2 := FloatArray withAll:#(2 2 2 3 3).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   488
     f1 *= f2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   489
     f1
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   490
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   491
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   492
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   493
primMulScalar: aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   494
    "multiply the scalar argument into the receiver (destructive)."
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   495
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   496
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   497
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   498
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   499
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   500
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   501
        float v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   502
        float prev_p1;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   503
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   504
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   505
            if (__isFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   506
                v = (float)(__floatVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   507
            } else  if (__isShortFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   508
                v = __shortFloatVal(aScalar);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   509
            } else if (__isSmallInteger(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   510
                v = (float)(__intVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   511
            } else
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   512
                goto badArg;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   513
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   514
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   515
            prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   516
            for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   517
                float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   518
                _p1[i-1] = prev_p1 * v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   519
                prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   520
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   521
            _p1[i-1] = prev_p1 * v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   522
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   523
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   524
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   525
    badArg: ;
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
    super primMulScalar:aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   528
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   529
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   530
     |f1 f2|
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
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   533
     f1 *= 2.0.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   534
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   535
     f1 *= 2.0 asShortFloat.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   536
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   537
     f1 *= 2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   538
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   539
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   540
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   541
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   542
primNegated
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   543
    "destructive negative value of each element"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   544
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   545
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   546
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   547
        INT _sz = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   548
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   549
        float *_p = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   550
        float prev_p;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   551
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   552
        if (_sz > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   553
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   554
            prev_p = _p[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   555
            for (i=1; i<_sz; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   556
                float next_p = _p[i];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   557
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   558
                _p[i-1] = -prev_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   559
                prev_p = next_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   560
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   561
            _p[i-1] = -prev_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   562
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   563
        RETURN (self);
17198
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
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   566
    super primNegated
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   567
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
     |f|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   570
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   571
     f := FloatArray withAll:#(-1 2 -3 4 -5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   572
     f negated.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   573
     f
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   574
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   575
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   576
    "Created: / 30-05-2007 / 17:51:29 / cg"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   577
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   578
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   579
primSubtractArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   580
    "subtract the vector argument from the receiver (destructive).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   581
     The argument must be another vector"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   582
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   583
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   584
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   585
     && __isFloats(floatArray)
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   586
     && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   587
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   588
        INT _sz2 = __floatArraySize(floatArray);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   589
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   590
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   591
        float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   592
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   593
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   594
            if (_sz2 >= _sz1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   595
                float prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   596
                float prev_p2 = _p2[0];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   597
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   598
                for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   599
                    float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   600
                    float next_p2 = _p2[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   601
                    _p1[i-1] = prev_p1 - prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   602
                    prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   603
                    prev_p2 = next_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   604
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   605
                _p1[i-1] = prev_p1 - prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   606
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   607
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   608
        RETURN (self);
17198
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
    super primSubtractArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   612
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
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   615
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   616
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   617
     f2 := FloatArray withAll:#(2 2 2 3 3).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   618
     f1 -= f2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   619
     f1
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   620
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   621
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   622
    "Created: / 30-05-2007 / 17:42:41 / cg"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   623
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   624
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   625
primSubtractScalar: aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   626
    "subtract the scalar argument from the receiver (destructive)."
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   627
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   628
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   629
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   630
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   631
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   632
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   633
        float v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   634
        float prev_p1;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   635
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   636
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   637
            if (__isFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   638
                v = (float)(__floatVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   639
            } else  if (__isShortFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   640
                v = __shortFloatVal(aScalar);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   641
            } else if (__isSmallInteger(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   642
                v = (float)(__intVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   643
            } else
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   644
                goto badArg;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   645
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   646
            /* how about inline-mmx-asm for this... ? */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   647
            prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   648
            for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   649
                float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   650
                _p1[i-1] = prev_p1 - v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   651
                prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   652
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   653
            _p1[i-1] = prev_p1 - v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   654
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   655
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   656
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   657
    badArg: ;
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
    super primSubtractScalar:aScalar
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
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   662
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   663
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   664
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   665
     f1 -= 2.0.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   666
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   667
     f1 -= 2.0 asShortFloat.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   668
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   669
     f1 -= 2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   670
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   671
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   672
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   673
    "Created: / 30-05-2007 / 17:43:06 / cg"
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   674
! !
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   675
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   676
!FloatArray methodsFor:'queries'!
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   677
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   678
defaultElement
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   679
    ^ ShortFloat zero
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   680
!
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   681
20300
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   682
isValidElement:anObject
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   683
    "return true, if I can hold this kind of object"
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   684
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   685
    ^ anObject isNumber
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   686
!
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   687
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   688
minMax
11212
8a6590cc1f4a comments
Claus Gittinger <cg@exept.de>
parents: 10580
diff changeset
   689
    "return a Tuple holding the smallest and largest element;
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   690
     redefined for speed"
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   691
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   692
    |min max empty|
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   693
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   694
%{
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 7220
diff changeset
   695
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   696
        INT _sz = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   697
        
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   698
        if (_sz > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   699
            INT _i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   700
            float *_p = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   701
            float _min, _max;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   702
            OBJ retVal;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   703
            
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   704
            _min = _max = _p[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   705
            for (_i=_sz-1; _i>0; _i-=2) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   706
                float _v1 = _p[_i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   707
                float _v2 = _p[_i-1];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   708
                if (_v1 < _v2) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   709
                    if (_v1 < _min) _min = _v1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   710
                    if (_v2 > _max) _max = _v2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   711
                } else {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   712
                    if (_v2 < _min) _min = _v2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   713
                    if (_v1 > _max) _max = _v1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   714
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   715
            }
21081
7c7d1c059ce9 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 20313
diff changeset
   716
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   717
            min = __MKFLOAT(_min);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   718
            __PROTECT__(min);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   719
            max = __MKFLOAT(_max);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   720
            __UNPROTECT__(min);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   721
            RETURN (__ARRAY_WITH2(min, max));
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
        empty = true;
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   724
    }
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   725
%}.
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   726
    empty == true ifTrue:[
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   727
        ^ self emptyCollectionError.
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   728
    ].
21081
7c7d1c059ce9 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 20313
diff changeset
   729
    ^ Array with:(self min) with:(self max)
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   730
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   731
    "
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   732
     |f1|
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   733
13774
f36d336cc5c0 changed: #minMax
Claus Gittinger <cg@exept.de>
parents: 13707
diff changeset
   734
     f1 := (1 to:10000) asFloatArray.
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   735
     Time millisecondsToRun:[ 1000 timesRepeat:[ f1 minMax ] ]
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   736
    "
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   737
    "
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   738
     |f1|
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   739
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   740
     f1 := FloatArray withAll:#(1 2 3 4 5).
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   741
     f1 minMax
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   742
    "
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   743
    "
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   744
     |f1|
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   745
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   746
     f1 := FloatArray withAll:#(1 2 3 4).
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   747
     f1 minMax
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   748
    "
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   749
    "
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   750
     |f1|
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   751
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   752
     f1 := FloatArray withAll:#(5 4 3 2 1).
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   753
     f1 minMax
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   754
    "
13774
f36d336cc5c0 changed: #minMax
Claus Gittinger <cg@exept.de>
parents: 13707
diff changeset
   755
f36d336cc5c0 changed: #minMax
Claus Gittinger <cg@exept.de>
parents: 13707
diff changeset
   756
    "Modified (comment): / 07-10-2011 / 13:03:30 / cg"
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   757
!
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   758
12577
a3224998ea6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11212
diff changeset
   759
numFloats
a3224998ea6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11212
diff changeset
   760
    ^ self size
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   761
! !
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   762
23798
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   763
!FloatArray methodsFor:'testing'!
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   764
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   765
isFloatArray
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   766
    "return true if the receiver has float elements.
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   767
     These are Float, Double- and HalfFloat arrays"
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   768
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   769
    ^ true
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   770
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   771
    "Created: / 02-03-2019 / 23:13:51 / Claus Gittinger"
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   772
!
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   773
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   774
isUnboxedFloatArray
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   775
    "return true if the receiver has float elements.
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   776
     These are Float, Double- and HalfFloat arrays"
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   777
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   778
    ^ true
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   779
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   780
    "Created: / 02-03-2019 / 23:13:26 / Claus Gittinger"
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   781
! !
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   782
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   783
!FloatArray methodsFor:'vector arithmetic'!
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   784
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   785
dot: aFloatVector
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   786
    "Return the dot product of the receiver and the argument.
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   787
     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
   788
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   789
    | mySize result |
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   790
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   791
"/    <primitive:'primitiveDotProduct' module: 'FloatArrayPlugin'>
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   792
%{
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   793
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   794
     && (__ClassInstPtr(__qClass(aFloatVector))->c_ninstvars == __mkSmallInteger(0))) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   795
        INT __mySize = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   796
        double __result = 0.0;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   797
        float *__p1 = __FloatArrayInstPtr(self)->f_element;
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   798
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   799
        if (__mySize > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   800
            if (__isFloats(aFloatVector)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   801
                INT __otherSize = __floatArraySize(aFloatVector);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
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
                    float *__p2 = __FloatArrayInstPtr(aFloatVector)->f_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
            } else if (__isDoubles(aFloatVector)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   813
                INT __otherSize = __doubleArraySize(aFloatVector);
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   814
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   815
                if (__mySize == __otherSize) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   816
                    double *__p2 = __DoubleArrayInstPtr(aFloatVector)->d_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   817
                    INT __i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   818
                    /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   819
                    for (__i=0; __i<__mySize; __i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   820
                        __result += (__p1[__i] * __p2[__i]);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   821
                    }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   822
                    RETURN (__MKFLOAT(__result));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   823
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   824
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   825
        }
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   826
    }
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   827
%}.
15935
35582e2e065c class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 14692
diff changeset
   828
    ^ super dot:aFloatVector
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   829
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   830
    "
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   831
     |v|
11212
8a6590cc1f4a comments
Claus Gittinger <cg@exept.de>
parents: 10580
diff changeset
   832
     v := #(2.0 2.0 1.0) asFloatArray.
19003
6ac2cb393fd7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 18577
diff changeset
   833
     v dot:v.
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   834
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   835
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   836
     v := #(2.0 2.0 1.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   837
     v dot:v.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   838
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   839
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   840
     v := #(2.0 2.0 1.0).
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   841
     v dot:v.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   842
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   843
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   844
     v1 := #(2.0 2.0 1.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   845
     v2 := #(2.0 2.0 1.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   846
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   847
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   848
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   849
     v1 := #(2.0 2.0 1.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   850
     v2 := #(2.0 2.0 1.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   851
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   852
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   853
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   854
     v1 := #(2.0 2.0 1.0).
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   855
     v2 := #(2.0 2.0 1.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   856
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   857
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   858
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   859
     v1 := #(2.0 2.0 1.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   860
     v2 := #(2.0 2.0 1.0).
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   861
     v1 dot:v2.
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
     v1 := #(2.0 2.0 1.0).
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   865
     v2 := #(2.0 2.0 1.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   866
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   867
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   868
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   869
     v1 := #(2.0 2.0 1.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   870
     v2 := #(2.0 2.0 1.0).
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   871
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   872
    "
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
   873
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   874
    "
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   875
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   876
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   877
     v1 := Array new:10000 withAll:2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   878
     v2 := Array new:10000 withAll:3.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   879
     Time millisecondsToRun:[
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   880
        10000 timesRepeat:[
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   881
          v1 dot:v2.
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   882
        ]
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   883
     ]
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   884
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   885
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   886
     |v1 v2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   887
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   888
     v1 := FloatArray new:10000 withAll:2.
19003
6ac2cb393fd7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 18577
diff changeset
   889
     v2 := FloatArray new:10000 withAll:3.
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   890
     Time millisecondsToRun:[
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   891
        10000 timesRepeat:[
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   892
          v1 dot:v2.
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   893
        ]
19003
6ac2cb393fd7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 18577
diff changeset
   894
     ]
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   895
    "
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   896
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   897
    "
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   898
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   899
     v1 := #(2.0 2.0 1.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   900
     v2 := #(2.0 2.0 1.0 0.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   901
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   902
    "
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   903
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
   904
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   905
    "Created: / 29-05-2007 / 13:13:39 / cg"
19032
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
hornerMultiplyAndAdd:x
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   909
    "primitive support for horner's-method computation of polynomials.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   910
     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
   911
        an*x^n + (an-1)*x^(n-1) + ... + a2(x) + a1
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   912
     where the ai are the elements of the Array.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   913
     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
   914
     This is inlined c-code, which may get compiled to fast machine code,
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   915
     using multiply-and-add or vector instructions, if the CPU/Compiler support them."
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   916
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   917
    | mySize result |
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   918
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   919
%{
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   920
    double __x;
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
   921
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   922
    if (__isFloat(x)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   923
        __x = __floatVal(x);
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   924
    } else if (__isShortFloat(x)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   925
        __x = (double)__shortFloatVal(x);
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   926
    } else if (__isSmallInteger(x)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   927
        __x = (double)(__intVal(x));
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   928
    } else {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   929
        goto getOutOfHere;
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   930
    }
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
   931
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   932
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   933
        INT __mySize = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   934
        float *__elements = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   935
        double __result = __elements[0];
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   936
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   937
        if (__mySize > 1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   938
            INT __i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   939
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   940
            for (__i=1; __i<__mySize; __i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   941
                __result = (__result * __x) + __elements[__i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   942
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   943
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   944
        RETURN (__MKFLOAT(__result));
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   945
    }
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
   946
getOutOfHere: ;
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   947
%}.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   948
    ^ super hornerMultiplyAndAdd:x
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   949
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 := #(2.0 3.0 4.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   953
     v  hornerMultiplyAndAdd:10.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   954
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   955
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   956
     v := Array new:100 withAll:2.0.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   957
     v hornerMultiplyAndAdd:10
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   958
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   959
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   960
     v := FloatArray new:100 withAll:2.0.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   961
     v hornerMultiplyAndAdd:10
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 := Array new:100 withAll:2.0.
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
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   969
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   970
     v := FloatArray new:100 withAll:2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   971
     Time millisecondsToRun:[
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   972
        10000 timesRepeat:[ v hornerMultiplyAndAdd:10]
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   973
     ]
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   974
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   975
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   976
     v := DoubleArray new:100 withAll:2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   977
     Time millisecondsToRun:[
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   978
        10000 timesRepeat:[ v hornerMultiplyAndAdd:10]
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   979
     ]
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   980
    "
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   981
! !
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   982
23798
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   983
628
7aa563e4c64a version at the end
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
   984
!FloatArray class methodsFor:'documentation'!
603
72bdeb24ccba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   985
72bdeb24ccba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   986
version
18577
72ff8078cb76 class: FloatArray
Stefan Vogel <sv@exept.de>
parents: 17198
diff changeset
   987
    ^ '$Header$'
12577
a3224998ea6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11212
diff changeset
   988
!
a3224998ea6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11212
diff changeset
   989
a3224998ea6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11212
diff changeset
   990
version_CVS
18577
72ff8078cb76 class: FloatArray
Stefan Vogel <sv@exept.de>
parents: 17198
diff changeset
   991
    ^ '$Header$'
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
   992
! !
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   993