[Newbies] Re: Primitives and array computation

Yoshiki Ohshima yoshiki at vpri.org
Thu Jul 10 22:30:13 UTC 2008


> So, I understand that I need:
> - intermediate classes, for storing 'true' arrays,
> - translators for converting to/from standard squeak classes from/to
> these intermediate classes,
> - primitives for array computation on these classes
> or something like that.

  The KedamaPlugin2 has some more operations defined, including the
mixed FloatArray and WordArray operations, and operations with
mask-bits.

  The following is probably a squeak-dev topic, but one thing that is
conceivable is to have a primitive that takes a function name as
string ('cos', 'sin', etc.) and in the primitive, it looks up the
symbol in various library can call it:

-----------------
  primApply: aString toArray: aFloatArray into: resultArray

      self var: 'val' type 'double'.
      func := dlsym(aString).
      0 to: aFloatArray size -1 do: [:i|
         val := aFloatArray at: i.
         resultArray at: i put: (self cCode: '(*func)(val)').
      ].

-----------------

-- Yoshiki


More information about the Beginners mailing list