To start numerical simulations, we first need the ability to set the initial condition. It will also be a good excercise for Paraiso building blocks, so let's give it a try. Please look at the example.
table :: Named (StaticValue TArray Double) table = "table" `isNameOf` StaticValue TArray undefined createBuilder :: Builder Vec2 Int Annotation () createBuilder = do x01 <- bind $ (cast $ loadIndex (Axis 0)) / (cast $ broadcast $ loadSize (Axis 0)) y01 <- bind $ (cast $ loadIndex (Axis 1)) / (cast $ broadcast $ loadSize (Axis 1)) x <- bind $ 4 * (x01-0.5) y <- bind $ 5 * (y01-0.5) z <- bind $ atan((1- x^2 - (y-(x^2)**(1/3))^2)*10) store table z
Generator.hs makes a bit tedious use of
broadcasts we have just learned, to calculate x and y coordinates in real number inbetween 0 and 1 (they are namely
y01.) See how input and output types for
broadcasts are inferred. The index and size are of type
Int (as specified in the type annotation for
z are all of type (Builder of)
table has that type and we cannot convert type without an explicit
cast. The careful reader also might have noticed that
1/3 is treated as
Double instead of just being truncated to
Now, Paraiso and the author give hearts to the readers! Thank you!