Satimage Previous | Next
Using arrays of real
Home Documentation Smile Computing Smile's maths Using arrays of real  
  • An array of real is an opaque class, logically equivalent to a list of real such as {1.0, 3.14}. Most numerical routines in Smile produce arrays of real, and they prefer arrays of real in input however most often Smile supports indifferently both types.

    You can coerce data from one type to another with the as keyword.
    set a to {0, pi} as array of real
      --  «data Lido4E6F7420 [...]»
    set x to a as list of real
      --  {0.0, 3.14159265359}


    Import script
  • Note that to make the array of real into a regular list of real (which is how you make an array of real legible) you have to use the virtual type list of real.
  • You can use as to convert between a list of arrays of real and a list of lists of real.
  • Note that you can also make the array of real into a regular list of integers: use as list of integer.
  • To make a new array of real with evenly spaced values use createarray.
    set b to createarray 41 range {-10, 10}
    b as list of real
      --  {-10.0, -9.5, -9.0, etc.}
  • To display the content of an array of real by script, use the display command, which makes an array of real into a human-readable text. Then, use for instance quietmsg to print the string to the Console.
    set b to createarray 41 range {-10, 10}
    set s to display y
    quietmsg(s)
  • To view rapidly an array of real use QuickCurve or QuickScatter.
    QuickCurve(0, b, 0)

    set c to randomarray 1000 range {-pi, pi}
    QuickScatter(0, c, 0)


    Import script
  • AppleScript cannot display NAN’s. When you coerce an array of real into a list of real numbers the NAN’s are translated into the special quantity missing value.
    set a to {0, pi} as array of real
    (asin a) as list of real
    -- {0.0, missing value}
  • To get the size of an array of real use count like with a regular list.
    count b
    -- 41
  • The mathematical functions defined in the Satimage osax work on numbers, on lists of real and on arrays of real.
    set d to cos b
    d as list of real
    -- {-0.839071529076, -0.997172156196, etc.}

QuickCurve


QuickScatter
Version française
Copyright ©2008 Paris, Satimage