FloatArray.st
author Stefan Vogel <sv@exept.de>
Tue, 28 Apr 2020 14:41:21 +0200
changeset 25372 389daab3ee10
parent 24436 e4f6ee192c0c
permissions -rw-r--r--
#DOCUMENTATION by stefan class: ReadWriteStream category of: #isEmpty #isReadable
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
24436
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    59
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
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"
24436
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    70
!
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    71
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    72
epsilon
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    73
    "return the maximum relative spacing of my elements
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    74
     (i.e. the value-delta of the least significant bit)"
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    75
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    76
    ^ ShortFloat epsilon
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    77
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    78
    "Created: / 19-07-2019 / 17:16:08 / Claus Gittinger"
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    79
!
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    80
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    81
precision
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    82
    "answer the precision (the number of bits in the mantissa) of my elements (in bits)
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    83
     This is an IEEE float, where only the fraction from the normalized mantissa is stored
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    84
     and so there is a hidden bit and the mantissa is actually represented by 24 binary digits
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    85
     (although only 23 are needed in the binary representation)"
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    86
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    87
    ^ ShortFloat precision
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    88
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    89
    "Created: / 19-07-2019 / 17:24:50 / Claus Gittinger"
13707
a8f395adfac2 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 12577
diff changeset
    90
! !
a8f395adfac2 faster elementByteSize query
Claus Gittinger <cg@exept.de>
parents: 12577
diff changeset
    91
24436
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
    92
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    93
!FloatArray methodsFor:'copying'!
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
clone
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    96
    "return a copy of the receiver"
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
    |newArr|
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    99
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   100
    newArr := self class new:(self size).
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   101
%{
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 7220
diff changeset
   102
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   103
        INT _sz = __floatArraySize(self);
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   104
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   105
        bcopy(__FloatArrayInstPtr(self)->f_element,
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   106
              __FloatArrayInstPtr(newArr)->f_element,
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   107
              sizeof(float) * _sz);
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   108
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   109
        RETURN (newArr);
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   110
    }
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   111
%}.
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   112
    newArr replaceFrom:1 to:self size with:self startingAt:1.
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   113
    ^ newArr
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   114
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   115
    "
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   116
     |f1 f2|
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   117
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   118
     f1 := FloatArray withAll:#(1 2 3 4 5).
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   119
     f1 clone
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   120
    "
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   121
!
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   122
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   123
copyFrom:start to:stop
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   124
    "return a partial copy of the receiver"
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   125
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   126
%{
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 7220
diff changeset
   127
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   128
        if (__bothSmallInteger(start, stop)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   129
            INT __start = __intVal(start) - 1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   130
            INT __stop = __intVal(stop) - 1 ;
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   131
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   132
            if (__stop >= __start) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   133
                INT __sz = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   134
                // printf("o_size=%d floatArraySize=%d\n", __qSize(self), __sz);
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   135
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   136
                if (((unsigned INT)__start < __sz)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   137
                 && ((unsigned INT)__stop < __sz)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   138
                    INT __n = __stop - __start + 1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   139
                    OBJ __nObj;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   140
                    int nBytes;
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   141
22263
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   142
                    // here we need to differ 32bit and 64bit
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   143
                    // because on 32bit machines we need to take care about the alignment
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   144
                    // but sadly, the same code is wrong for 64bit machines
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   145
                    if (__POINTER_SIZE__ == 8) {
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   146
                        nBytes = OHDR_SIZE + (__n * sizeof(float));
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   147
                    } else {
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   148
                        nBytes = sizeof(struct __FloatArray) + (__n - 1) * sizeof(float);
13169b366d63 #BUGFIX by sr
sr
parents: 22257
diff changeset
   149
                    }
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
   150
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   151
                    // printf("__n=%d nBytes=%d\n", __n, nBytes);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   152
                    __nObj = __STX___new(nBytes);
22257
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   153
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   154
                    if (__nObj != nil) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   155
                        __objPtr(__nObj)->o_class = __qClass(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   156
                        __STORE(__nObj, __qClass(self));
22257
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   157
                        // bcopy is marked as deprecated
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   158
                        // bcopy(
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   159
                        //     __FloatArrayInstPtr(self)->f_element,   
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   160
                        //     __FloatArrayInstPtr(__nObj)->f_element + __start,  
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   161
                        //     __n * sizeof(float));
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   162
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   163
                        memcpy(
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   164
                            __FloatArrayInstPtr(__nObj)->f_element + __start,
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   165
                            __FloatArrayInstPtr(self)->f_element,
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   166
                            __n * sizeof(float));
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   167
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   168
                        RETURN(__nObj);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   169
                    }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   170
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   171
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   172
        }
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   173
    }
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   174
%}.
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   175
    ^ super copyFrom:start to:stop
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   176
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   177
    "
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   178
     |f1 f2|
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   179
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   180
     f1 := FloatArray withAll:#(1 2 3 4 5 6).
22257
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   181
     f2 := f1 copyFrom:1 to:3.
9ce7e373cf91 #BUGFIX by sr
sr
parents: 21081
diff changeset
   182
     f2                      
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   183
    "
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   184
!
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   185
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   186
replaceFrom:start to:stop with:aCollection startingAt:replStart
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   187
%{
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 7220
diff changeset
   188
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   189
         && __isFloats(aCollection)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   190
         && (__ClassInstPtr(__qClass(aCollection))->c_ninstvars == __mkSmallInteger(0))
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   191
         && __bothSmallInteger(start, stop)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   192
         && __isSmallInteger(replStart)
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   193
         && !__isImmutable(self)
18577
72ff8078cb76 class: FloatArray
Stefan Vogel <sv@exept.de>
parents: 17198
diff changeset
   194
    ) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   195
        INT __start = __intVal(start) - 1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   196
        INT __stop = __intVal(stop) - 1 ;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   197
        INT __replStart = __intVal(replStart) - 1 ;
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   198
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   199
        if (__stop >= __start) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   200
            INT __sz = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   201
            INT __otherSz = __floatArraySize(aCollection);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   202
            INT __replStop = __replStart + (__stop-__start);
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   203
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   204
            if (((unsigned INT)__start < __sz)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   205
             && ((unsigned INT)__stop < __sz)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   206
             && ((unsigned INT)__replStart < __otherSz)
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   207
             && ((unsigned INT)__replStop < __otherSz)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   208
                INT __n = __stop - __start + 1;
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   209
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   210
                if (aCollection == self) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   211
                    memmove(&(__FloatArrayInstPtr(self)->f_element[__start]),
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   212
                            &(__FloatArrayInstPtr(aCollection)->f_element[__replStart]),
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   213
                            sizeof(float) * __n);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   214
                } else {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   215
                    memcpy(&(__FloatArrayInstPtr(self)->f_element[__start]),
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   216
                           &(__FloatArrayInstPtr(aCollection)->f_element[__replStart]),
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   217
                           sizeof(float) * __n);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   218
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   219
                RETURN(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   220
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   221
        }
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   222
    }
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   223
%}.
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   224
    "/ arrive here only in case of an error
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   225
    self isImmutable ifTrue:[
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   226
        self noModificationError
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   227
    ].    
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   228
    ^ super replaceFrom:start to:stop with:aCollection startingAt:replStart
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   229
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   230
    "
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   231
     |f1 f2|
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   232
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   233
     f1 := (1 to:5) asFloatArray.
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   234
     f2 := #(10 9 8 7 6) asFloatArray.
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   235
     f1 replaceFrom:1 to:3 with:f2 startingAt:3
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   236
    "
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   237
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   238
    "Modified: / 09-06-2019 / 15:33:14 / Claus Gittinger"
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   239
! !
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   240
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   241
!FloatArray methodsFor:'destructive arithmetic support'!
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
primAbs
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   244
    "destructive absolute value of each element;
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   245
     does not check for immutability: only use internally after cloning"
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   246
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   247
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   248
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   249
        INT _sz = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   250
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   251
        float *_p = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   252
        float prev_p;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   253
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   254
        if (_sz > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   255
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   256
            prev_p = _p[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   257
            for (i=1; i<_sz; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   258
                float next_p = _p[i];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   259
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   260
                if (prev_p < 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   261
                    _p[i-1] = -prev_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   262
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   263
                prev_p = next_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   264
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   265
            if (prev_p < 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   266
                _p[i-1] = -prev_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   267
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   268
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   269
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   270
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   271
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   272
    super primAbs
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   273
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   274
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   275
     |f|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   276
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   277
     f := FloatArray withAll:#(-1 2 -3 4 -5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   278
     f abs.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   279
     f
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   280
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   281
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   282
    "Created: / 30-05-2007 / 17:50:17 / cg"
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   283
    "Modified (comment): / 09-06-2019 / 15:34:21 / Claus Gittinger"
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   284
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   285
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   286
primAddArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   287
    "add the vector argument into the receiver (destructive).
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   288
     The argument must be another vector.
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   289
     does not check for immutability: only use internally after cloning"
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   290
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   291
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   292
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   293
     && __isFloats(floatArray)
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   294
     && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   295
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   296
        INT _sz2 = __floatArraySize(floatArray);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   297
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   298
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   299
        float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   300
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   301
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   302
            if (_sz2 >= _sz1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   303
                /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   304
                float prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   305
                float prev_p2 = _p2[0];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   306
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   307
                for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   308
                    float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   309
                    float next_p2 = _p2[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   310
                    _p1[i-1] = prev_p1 + prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   311
                    prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   312
                    prev_p2 = next_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   313
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   314
                _p1[i-1] = prev_p1 + prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   315
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   316
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   317
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   318
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   319
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   320
    super primAddArray:floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   321
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   322
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   323
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   324
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   325
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   326
     f2 := FloatArray withAll:#(2 2 2 3 3).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   327
     f1 += f2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   328
     f1
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   329
    "
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   330
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   331
    "Modified (comment): / 09-06-2019 / 15:34:31 / Claus Gittinger"
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   332
!
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
primAddScalar: aScalar
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   335
    "add the scalar argument into the receiver (destructive).
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   336
     does not check for immutability: only use internally after cloning"
17198
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
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   340
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   341
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   342
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   343
        float v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   344
        float prev_p1;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   345
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   346
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   347
            if (__isFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   348
                v = (float)(__floatVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   349
            } else  if (__isShortFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   350
                v = __shortFloatVal(aScalar);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   351
            } else if (__isSmallInteger(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   352
                v = (float)(__intVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   353
            } else
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   354
                goto badArg;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   355
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   356
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   357
            prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   358
            for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   359
                float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   360
                _p1[i-1] = prev_p1 + v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   361
                prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   362
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   363
            _p1[i-1] = prev_p1 + v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   364
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   365
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   366
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   367
    badArg: ;
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   368
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   369
    super primAddScalar:aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   370
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   371
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   372
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   373
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   374
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   375
     f1 += 2.0.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   376
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   377
     f1 += 2.0 asShortFloat.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   378
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   379
     f1 += 2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   380
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   381
    "
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   382
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   383
    "Modified (comment): / 09-06-2019 / 15:34:37 / Claus Gittinger"
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   384
!
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
primDivArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   387
    "divide the vector argument into the receiver (destructive).
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   388
     The argument must be another vector.
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   389
     does not check for immutability: only use internally after cloning"
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   390
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   391
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   392
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   393
     && __isFloats(floatArray)
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   394
     && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   395
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   396
        INT _sz2 = __floatArraySize(floatArray);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   397
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   398
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   399
        float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   400
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   401
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   402
            if (_sz2 >= _sz1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   403
                /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   404
                float prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   405
                float prev_p2 = _p2[0];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   406
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   407
                for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   408
                    float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   409
                    float next_p2 = _p2[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   410
                    _p1[i-1] = prev_p1 / prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   411
                    prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   412
                    prev_p2 = next_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   413
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   414
                _p1[i-1] = prev_p1 / prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   415
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   416
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   417
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   418
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   419
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   420
    super primDivArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   421
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   422
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   423
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   424
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   425
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   426
     f2 := FloatArray withAll:#(2 2 2 3 3).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   427
     f1 /= f2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   428
     f1
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
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   431
    "Modified: / 29-05-2007 / 16:01:34 / cg"
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   432
    "Modified (comment): / 09-06-2019 / 15:34:43 / Claus Gittinger"
17198
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
primDivScalar: aScalar
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   436
    "divide the scalar argument into the receiver (destructive).
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   437
     does not check for immutability: only use internally after cloning"
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   438
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   439
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   440
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   441
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   442
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   443
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   444
        float v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   445
        float prev_p1;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   446
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   447
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   448
            if (__isFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   449
                v = (float)(__floatVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   450
            } else  if (__isShortFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   451
                v = __shortFloatVal(aScalar);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   452
            } else if (__isSmallInteger(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   453
                v = (float)(__intVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   454
            } else
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   455
                goto badArg;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   456
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   457
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   458
            prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   459
            for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   460
                float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   461
                _p1[i-1] = prev_p1 / v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   462
                prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   463
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   464
            _p1[i-1] = prev_p1 / v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   465
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   466
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   467
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   468
    badArg: ;
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   469
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   470
    super primDivScalar:aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   471
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   472
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   473
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   474
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   475
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   476
     f1 /= 2.0.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   477
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   478
     f1 /= 2.0 asShortFloat.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   479
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   480
     f1 /= 2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   481
     Transcript showCR:f1.
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
    "Modified: / 29-05-2007 / 16:01:39 / cg"
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   485
    "Modified (comment): / 09-06-2019 / 15:34:48 / Claus Gittinger"
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   486
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   487
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   488
primMulArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   489
    "multiply the vector argument into the receiver (destructive).
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   490
     The argument must be another vector.
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   491
     does not check for immutability: only use internally after cloning"
17198
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
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   494
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   495
     && __isFloats(floatArray)
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   496
     && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   497
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   498
        INT _sz2 = __floatArraySize(floatArray);
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 *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   502
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   503
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   504
            if (_sz2 >= _sz1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   505
                float prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   506
                float prev_p2 = _p2[0];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   507
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   508
                for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   509
                    float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   510
                    float next_p2 = _p2[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   511
                    _p1[i-1] = prev_p1 * prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   512
                    prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   513
                    prev_p2 = next_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   514
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   515
                _p1[i-1] = prev_p1 * prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   516
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   517
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   518
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   519
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   520
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   521
    super primMulArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   522
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   523
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   524
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   525
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   526
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   527
     f2 := FloatArray withAll:#(2 2 2 3 3).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   528
     f1 *= f2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   529
     f1
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   530
    "
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   531
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   532
    "Modified (comment): / 09-06-2019 / 15:34:53 / Claus Gittinger"
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   533
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   534
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   535
primMulScalar: aScalar
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   536
    "multiply the scalar argument into the receiver (destructive).
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   537
     does not check for immutability: only use internally after cloning"
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   538
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
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   541
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   542
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   543
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   544
        float v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   545
        float prev_p1;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   546
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   547
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   548
            if (__isFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   549
                v = (float)(__floatVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   550
            } else  if (__isShortFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   551
                v = __shortFloatVal(aScalar);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   552
            } else if (__isSmallInteger(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   553
                v = (float)(__intVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   554
            } else
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   555
                goto badArg;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   556
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   557
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   558
            prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   559
            for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   560
                float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   561
                _p1[i-1] = prev_p1 * v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   562
                prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   563
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   564
            _p1[i-1] = prev_p1 * v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   565
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   566
        RETURN (self);
17198
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
    badArg: ;
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   569
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   570
    super primMulScalar:aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   571
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   572
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   573
     |f1 f2|
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
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   576
     f1 *= 2.0.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   577
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   578
     f1 *= 2.0 asShortFloat.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   579
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   580
     f1 *= 2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   581
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   582
    "
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   583
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   584
    "Modified (comment): / 09-06-2019 / 15:35:00 / Claus Gittinger"
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   585
!
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   586
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   587
primNegated
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   588
    "destructive negative value of each element.
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   589
     does not check for immutability: only use internally after cloning"
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   590
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   591
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   592
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   593
        INT _sz = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   594
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   595
        float *_p = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   596
        float prev_p;
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
        if (_sz > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   599
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   600
            prev_p = _p[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   601
            for (i=1; i<_sz; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   602
                float next_p = _p[i];
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   603
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   604
                _p[i-1] = -prev_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   605
                prev_p = next_p;
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
            _p[i-1] = -prev_p;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   608
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   609
        RETURN (self);
17198
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
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   612
    super primNegated
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   613
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   614
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   615
     |f|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   616
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   617
     f := FloatArray withAll:#(-1 2 -3 4 -5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   618
     f negated.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   619
     f
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:51:29 / cg"
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   623
    "Modified (comment): / 09-06-2019 / 15:35:04 / Claus Gittinger"
17198
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
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   626
primSubtractArray: floatArray
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   627
    "subtract the vector argument from the receiver (destructive).
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   628
     The argument must be another vector.
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   629
     does not check for immutability: only use internally after cloning"
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   630
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   631
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   632
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   633
     && __isFloats(floatArray)
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   634
     && (__ClassInstPtr(__qClass(floatArray))->c_ninstvars == __mkSmallInteger(0))) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   635
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   636
        INT _sz2 = __floatArraySize(floatArray);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   637
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   638
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   639
        float *_p2 = __FloatArrayInstPtr(floatArray)->f_element;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   640
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   641
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   642
            if (_sz2 >= _sz1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   643
                float prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   644
                float prev_p2 = _p2[0];
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
                for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   647
                    float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   648
                    float next_p2 = _p2[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   649
                    _p1[i-1] = prev_p1 - prev_p2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   650
                    prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   651
                    prev_p2 = next_p2;
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 - prev_p2;
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
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   656
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   657
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   658
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   659
    super primSubtractArray: floatArray
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
     f2 := FloatArray withAll:#(2 2 2 3 3).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   666
     f1 -= f2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   667
     f1
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   668
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   669
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   670
    "Created: / 30-05-2007 / 17:42:41 / cg"
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   671
    "Modified (comment): / 09-06-2019 / 15:35:08 / Claus Gittinger"
17198
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
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   674
primSubtractScalar: aScalar
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   675
    "subtract the scalar argument from the receiver (destructive).
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   676
     does not check for immutability: only use internally after cloning"
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   677
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   678
%{
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   679
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   680
        INT _sz1 = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   681
        INT i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   682
        float *_p1 = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   683
        float v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   684
        float prev_p1;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   685
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   686
        if (_sz1 > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   687
            if (__isFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   688
                v = (float)(__floatVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   689
            } else  if (__isShortFloat(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   690
                v = __shortFloatVal(aScalar);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   691
            } else if (__isSmallInteger(aScalar)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   692
                v = (float)(__intVal(aScalar));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   693
            } else
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   694
                goto badArg;
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   695
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   696
            /* how about inline-mmx-asm for this... ? */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   697
            prev_p1 = _p1[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   698
            for (i=1; i<_sz1; i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   699
                float next_p1 = _p1[i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   700
                _p1[i-1] = prev_p1 - v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   701
                prev_p1 = next_p1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   702
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   703
            _p1[i-1] = prev_p1 - v;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   704
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   705
        RETURN (self);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   706
    }
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   707
    badArg: ;
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   708
%}.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   709
    super primSubtractScalar:aScalar
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   710
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   711
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   712
     |f1 f2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   713
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   714
     f1 := FloatArray withAll:#(1 2 3 4 5).
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   715
     f1 -= 2.0.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   716
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   717
     f1 -= 2.0 asShortFloat.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   718
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   719
     f1 -= 2.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   720
     Transcript showCR:f1.
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   721
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   722
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   723
    "Created: / 30-05-2007 / 17:43:06 / cg"
24318
6c2c7bd1c70c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 24308
diff changeset
   724
    "Modified (comment): / 09-06-2019 / 15:35:13 / Claus Gittinger"
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   725
! !
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   726
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   727
!FloatArray methodsFor:'queries'!
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   728
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   729
defaultElement
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   730
    ^ ShortFloat zero
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
20300
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   733
isValidElement:anObject
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   734
    "return true, if I can hold this kind of object"
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   735
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   736
    ^ anObject isNumber
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   737
!
b67a6d272129 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19032
diff changeset
   738
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   739
minMax
11212
8a6590cc1f4a comments
Claus Gittinger <cg@exept.de>
parents: 10580
diff changeset
   740
    "return a Tuple holding the smallest and largest element;
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   741
     redefined for speed"
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   742
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   743
    |min max empty|
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   744
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   745
%{
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 7220
diff changeset
   746
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   747
        INT _sz = __floatArraySize(self);
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
        if (_sz > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   750
            INT _i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   751
            float *_p = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   752
            float _min, _max;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   753
            OBJ retVal;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   754
            
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   755
            _min = _max = _p[0];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   756
            for (_i=_sz-1; _i>0; _i-=2) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   757
                float _v1 = _p[_i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   758
                float _v2 = _p[_i-1];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   759
                if (_v1 < _v2) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   760
                    if (_v1 < _min) _min = _v1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   761
                    if (_v2 > _max) _max = _v2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   762
                } else {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   763
                    if (_v2 < _min) _min = _v2;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   764
                    if (_v1 > _max) _max = _v1;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   765
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   766
            }
21081
7c7d1c059ce9 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 20313
diff changeset
   767
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   768
            min = __MKFLOAT(_min);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   769
            __PROTECT__(min);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   770
            max = __MKFLOAT(_max);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   771
            __UNPROTECT__(min);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   772
            RETURN (__ARRAY_WITH2(min, max));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   773
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   774
        empty = true;
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   775
    }
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   776
%}.
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   777
    empty == true ifTrue:[
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   778
        ^ self emptyCollectionError.
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   779
    ].
21081
7c7d1c059ce9 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 20313
diff changeset
   780
    ^ Array with:(self min) with:(self max)
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   781
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   782
    "
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   783
     |f1|
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   784
13774
f36d336cc5c0 changed: #minMax
Claus Gittinger <cg@exept.de>
parents: 13707
diff changeset
   785
     f1 := (1 to:10000) asFloatArray.
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   786
     Time millisecondsToRun:[ 1000 timesRepeat:[ f1 minMax ] ]
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   787
    "
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   788
    "
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   789
     |f1|
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   790
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   791
     f1 := FloatArray withAll:#(1 2 3 4 5).
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   792
     f1 minMax
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   793
    "
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   794
    "
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   795
     |f1|
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   796
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   797
     f1 := FloatArray withAll:#(1 2 3 4).
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   798
     f1 minMax
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   799
    "
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   800
    "
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   801
     |f1|
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   802
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   803
     f1 := FloatArray withAll:#(5 4 3 2 1).
14692
98e7a51e5d17 64bit fixes
Claus Gittinger <cg@exept.de>
parents: 13826
diff changeset
   804
     f1 minMax
7220
5225d13b2d57 inheritance & documentation
Claus Gittinger <cg@exept.de>
parents: 5816
diff changeset
   805
    "
13774
f36d336cc5c0 changed: #minMax
Claus Gittinger <cg@exept.de>
parents: 13707
diff changeset
   806
f36d336cc5c0 changed: #minMax
Claus Gittinger <cg@exept.de>
parents: 13707
diff changeset
   807
    "Modified (comment): / 07-10-2011 / 13:03:30 / cg"
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   808
!
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   809
12577
a3224998ea6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11212
diff changeset
   810
numFloats
a3224998ea6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11212
diff changeset
   811
    ^ self size
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   812
! !
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   813
23798
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   814
!FloatArray methodsFor:'testing'!
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   815
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   816
isFloatArray
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   817
    "return true if the receiver has float elements.
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   818
     These are Float, Double- and HalfFloat arrays"
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   819
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   820
    ^ true
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   821
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   822
    "Created: / 02-03-2019 / 23:13:51 / Claus Gittinger"
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   823
!
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   824
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   825
isUnboxedFloatArray
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   826
    "return true if the receiver has float elements.
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   827
     These are Float, Double- and HalfFloat arrays"
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   828
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   829
    ^ true
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   830
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   831
    "Created: / 02-03-2019 / 23:13:26 / Claus Gittinger"
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   832
! !
300f01ecb7f0 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 22263
diff changeset
   833
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   834
!FloatArray methodsFor:'vector arithmetic'!
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   835
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   836
dot: aFloatVector
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   837
    "Return the dot product of the receiver and the argument.
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   838
     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
   839
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   840
    | mySize result |
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   841
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   842
"/    <primitive:'primitiveDotProduct' module: 'FloatArrayPlugin'>
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   843
%{
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   844
    if ((__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0))
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   845
     && (__ClassInstPtr(__qClass(aFloatVector))->c_ninstvars == __mkSmallInteger(0))) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   846
        INT __mySize = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   847
        double __result = 0.0;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   848
        float *__p1 = __FloatArrayInstPtr(self)->f_element;
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   849
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   850
        if (__mySize > 0) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   851
            if (__isFloats(aFloatVector)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   852
                INT __otherSize = __floatArraySize(aFloatVector);
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   853
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   854
                if (__mySize == __otherSize) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   855
                    float *__p2 = __FloatArrayInstPtr(aFloatVector)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   856
                    INT __i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   857
                    /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   858
                    for (__i=0; __i<__mySize; __i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   859
                        __result += (__p1[__i] * __p2[__i]);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   860
                    }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   861
                    RETURN (__MKFLOAT(__result));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   862
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   863
            } else if (__isDoubles(aFloatVector)) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   864
                INT __otherSize = __doubleArraySize(aFloatVector);
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   865
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   866
                if (__mySize == __otherSize) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   867
                    double *__p2 = __DoubleArrayInstPtr(aFloatVector)->d_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   868
                    INT __i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   869
                    /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   870
                    for (__i=0; __i<__mySize; __i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   871
                        __result += (__p1[__i] * __p2[__i]);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   872
                    }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   873
                    RETURN (__MKFLOAT(__result));
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   874
                }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   875
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   876
        }
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   877
    }
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   878
%}.
15935
35582e2e065c class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 14692
diff changeset
   879
    ^ super dot:aFloatVector
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   880
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   881
    "
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   882
     |v|
11212
8a6590cc1f4a comments
Claus Gittinger <cg@exept.de>
parents: 10580
diff changeset
   883
     v := #(2.0 2.0 1.0) asFloatArray.
19003
6ac2cb393fd7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 18577
diff changeset
   884
     v dot:v.
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   885
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   886
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   887
     v := #(2.0 2.0 1.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   888
     v dot:v.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   889
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   890
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   891
     v := #(2.0 2.0 1.0).
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   892
     v dot:v.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   893
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   894
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   895
     v1 := #(2.0 2.0 1.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   896
     v2 := #(2.0 2.0 1.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   897
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   898
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   899
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   900
     v1 := #(2.0 2.0 1.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   901
     v2 := #(2.0 2.0 1.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   902
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   903
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   904
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   905
     v1 := #(2.0 2.0 1.0).
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   906
     v2 := #(2.0 2.0 1.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   907
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   908
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   909
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   910
     v1 := #(2.0 2.0 1.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   911
     v2 := #(2.0 2.0 1.0).
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   912
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   913
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   914
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   915
     v1 := #(2.0 2.0 1.0).
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   916
     v2 := #(2.0 2.0 1.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   917
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   918
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   919
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   920
     v1 := #(2.0 2.0 1.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   921
     v2 := #(2.0 2.0 1.0).
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   922
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   923
    "
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
   924
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   925
    "
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   926
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   927
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   928
     v1 := Array new:10000 withAll:2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   929
     v2 := Array new:10000 withAll:3.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   930
     Time millisecondsToRun:[
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   931
        10000 timesRepeat:[
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   932
          v1 dot:v2.
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   933
        ]
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   934
     ]
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   935
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   936
    "
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   937
     |v1 v2|
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   938
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   939
     v1 := FloatArray new:10000 withAll:2.
19003
6ac2cb393fd7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 18577
diff changeset
   940
     v2 := FloatArray new:10000 withAll:3.
17198
7518cd20d9d3 class: FloatArray
Claus Gittinger <cg@exept.de>
parents: 16849
diff changeset
   941
     Time millisecondsToRun:[
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   942
        10000 timesRepeat:[
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   943
          v1 dot:v2.
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
   944
        ]
19003
6ac2cb393fd7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 18577
diff changeset
   945
     ]
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   946
    "
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   947
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   948
    "
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   949
     |v1 v2|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   950
     v1 := #(2.0 2.0 1.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   951
     v2 := #(2.0 2.0 1.0 0.0) asDoubleArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   952
     v1 dot:v2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   953
    "
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   954
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
   955
10561
6987bd25c09d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
   956
    "Created: / 29-05-2007 / 13:13:39 / cg"
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   957
!
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
   958
24306
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   959
esum
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   960
    "Return the (double) sum of the elements.
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   961
     Reduces accumulated rounding errors.
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   962
     This is an experimental algorithm"
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   963
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   964
%{
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   965
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   966
        INT __mySize = __floatArraySize(self);
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   967
        double __sum = 0.0;
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   968
        float *__pf = __FloatArrayInstPtr(self)->f_element;
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   969
        #define NBITS_EXP 11
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   970
        #define NIDX_EXP  ((1<<NBITS_EXP))
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   971
        #define MASK_EXP  (NIDX_EXP-1)
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   972
        double sumsPerE[ NIDX_EXP];
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   973
        int __i, __minIdx = MASK_EXP, __maxIdx = 0;
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   974
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   975
        memset(sumsPerE, 0, sizeof(double)*NIDX_EXP);
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   976
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   977
        for (__i=0; __i<__mySize; __i++) {
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   978
            union {
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   979
                double f;
24333
e6d6a165972d Replace uint32_t (not known in mingw)
Stefan Vogel <sv@exept.de>
parents: 24318
diff changeset
   980
                unsigned int32 ui32[2];
24306
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   981
            } u;
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   982
            int exp;
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   983
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   984
            u.f = (double)__pf[__i];
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   985
#ifdef __LSBFIRST__
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   986
            exp = (u.ui32[1] >> (32-1-NBITS_EXP)) & MASK_EXP;
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   987
#else
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   988
            exp = (u.ui32[0] >> ((32-1-NBITS_EXP)) & MASK_EXP;
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   989
#endif
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   990
            // printf("f:%04x %04x %04x %04x\n", u.ui32[0], u.ui32[1], u.ui32[2], u.ui32[3]); 
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   991
            // printf("e:%d %lf + %lf -> %lf\n", exp, sumsPerE[exp], u.f, (sumsPerE[exp]+u.f)); 
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   992
            sumsPerE[exp] += u.f;
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   993
            __minIdx = exp < __minIdx ? exp : __minIdx;
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   994
            __maxIdx = exp > __maxIdx ? exp : __maxIdx;
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   995
        }
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   996
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   997
        // printf("low:%d high:%d\n", __minIdx, __maxIdx);
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   998
        for (__i=__maxIdx; __i>=__minIdx; __i--) {
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
   999
            __sum += sumsPerE[__i];
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1000
        }
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1001
        RETURN (__MKFLOAT(__sum));
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1002
    }
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1003
%}.
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1004
    ^ super sum
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1005
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1006
    "here, sum and esum both deliver the same result
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1007
    
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1008
     |v|
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1009
     v := #(2.0 2.0 1.0 1.0) asFloatArray.
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1010
     v sum.
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1011
     v esum.
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1012
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1013
     |v|
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1014
     v := #(1e38 1.0 -1e38 1.0) asFloatArray.
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1015
     v sum.
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1016
     v esum.
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1017
    "
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1018
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1019
    "Created: / 09-06-2019 / 14:10:58 / Claus Gittinger"
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1020
!
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1021
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1022
hornerMultiplyAndAdd:x
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1023
    "primitive support for horner's-method computation of polynomials.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1024
     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
  1025
        an*x^n + (an-1)*x^(n-1) + ... + a2(x) + a1
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1026
     where the ai are the elements of the Array.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1027
     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
  1028
     This is inlined c-code, which may get compiled to fast machine code,
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1029
     using multiply-and-add or vector instructions, if the CPU/Compiler support them."
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1030
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1031
    | mySize result |
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1033
%{
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1034
    double __x;
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
  1035
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1036
    if (__isFloat(x)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1037
        __x = __floatVal(x);
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1038
    } else if (__isShortFloat(x)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1039
        __x = (double)__shortFloatVal(x);
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1040
    } else if (__isSmallInteger(x)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1041
        __x = (double)(__intVal(x));
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1042
    } else {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1043
        goto getOutOfHere;
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1044
    }
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
  1045
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1046
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1047
        INT __mySize = __floatArraySize(self);
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1048
        float *__elements = __FloatArrayInstPtr(self)->f_element;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1049
        double __result = __elements[0];
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1050
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1051
        if (__mySize > 1) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1052
            INT __i;
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1053
            /* how about inline-mmx-asm for this ... */
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1054
            for (__i=1; __i<__mySize; __i++) {
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1055
                __result = (__result * __x) + __elements[__i];
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1056
            }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1057
        }
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1058
        RETURN (__MKFLOAT(__result));
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1059
    }
20303
060fea1cfebe fixes for float/doubleArray alignemnt
Claus Gittinger <cg@exept.de>
parents: 20300
diff changeset
  1060
getOutOfHere: ;
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1061
%}.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1062
    ^ super hornerMultiplyAndAdd:x
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1063
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1064
    "
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1065
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1066
     v := #(2.0 3.0 4.0) asFloatArray.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1067
     v  hornerMultiplyAndAdd:10.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1068
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1069
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1070
     v := Array new:100 withAll:2.0.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1071
     v hornerMultiplyAndAdd:10
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1072
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1073
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1074
     v := FloatArray new:100 withAll:2.0.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1075
     v hornerMultiplyAndAdd:10
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1076
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1077
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1078
     v := Array new:100 withAll:2.0.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1079
     Time millisecondsToRun:[
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1080
        10000 timesRepeat:[ v hornerMultiplyAndAdd:10]
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1081
     ]
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1082
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1083
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1084
     v := FloatArray new:100 withAll:2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1085
     Time millisecondsToRun:[
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1086
        10000 timesRepeat:[ v hornerMultiplyAndAdd:10]
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1087
     ]
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1088
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1089
     |v|
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1090
     v := DoubleArray new:100 withAll:2.
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1091
     Time millisecondsToRun:[
20313
1280e2eafb73 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 20303
diff changeset
  1092
        10000 timesRepeat:[ v hornerMultiplyAndAdd:10]
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1093
     ]
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1094
    "
24306
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1095
!
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1096
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1097
sum
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1098
    "Return the (double) sum of the elements.
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1099
     May suffer from accumulated rounding error"
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1100
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1101
%{
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1102
    if (__ClassInstPtr(__qClass(self))->c_ninstvars == __mkSmallInteger(0)) {
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1103
        INT __mySize = __floatArraySize(self);
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1104
        double __sum = 0.0;
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1105
        float *__pf = __FloatArrayInstPtr(self)->f_element;
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1106
        int __i;
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1107
        
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1108
        /* how about inline-mmx-asm for this ... */
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1109
        for (__i=0; __i<__mySize; __i++) {
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1110
            __sum += __pf[__i];
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1111
        }
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1112
        RETURN (__MKFLOAT(__sum));
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1113
    }
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1114
%}.
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1115
    ^ super sum
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1116
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1117
    "
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1118
     |v|
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1119
     v := #(2.0 2.0 1.0) asFloatArray.
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1120
     v sum.
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1121
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1122
     |v|
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1123
     v := #(1e30 1 -1e30 1) asFloatArray.
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1124
     v sum.
24308
c18e6b171db6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24306
diff changeset
  1125
     v esum.
24306
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1126
    "
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1127
ee7c9f895369 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 23806
diff changeset
  1128
    "Created: / 09-06-2019 / 10:41:12 / Claus Gittinger"
24308
c18e6b171db6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 24306
diff changeset
  1129
    "Modified (comment): / 09-06-2019 / 14:14:47 / Claus Gittinger"
5737
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
  1130
! !
1e4a1b0c294e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
  1131
24436
e4f6ee192c0c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 24333
diff changeset
  1132
628
7aa563e4c64a version at the end
Claus Gittinger <cg@exept.de>
parents: 603
diff changeset
  1133
!FloatArray class methodsFor:'documentation'!
603
72bdeb24ccba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1134
72bdeb24ccba checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1135
version
18577
72ff8078cb76 class: FloatArray
Stefan Vogel <sv@exept.de>
parents: 17198
diff changeset
  1136
    ^ '$Header$'
12577
a3224998ea6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11212
diff changeset
  1137
!
a3224998ea6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11212
diff changeset
  1138
a3224998ea6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11212
diff changeset
  1139
version_CVS
18577
72ff8078cb76 class: FloatArray
Stefan Vogel <sv@exept.de>
parents: 17198
diff changeset
  1140
    ^ '$Header$'
88
81dacba7a63a *** empty log message ***
claus
parents: 3
diff changeset
  1141
! !
19032
67c02dbf742d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 19003
diff changeset
  1142