class SimpleAvg(i: Dim) extends Program(i) {
val iarr = IntsVar
var output = IntsVar
content = output(i) := (iarr(i - 1) + iarr(i) + iarr(i + 1)) / 3
}
Obviously this does not work for the first and last elements as the
index for previous and next element will be outside the array.
Typically giving errors like this:
"Inferred weird array usage for array variable 'in' (MinMax
(-1.0,9.0)). Please allocate it explicitely in its constructor."
In my original code you can see me checking for i == 0 and i ==
arr.size - 1. Is there any way I can have these kind of constraints in
the ScalaCL-code?
Or do you have suggestions how to achieve the same
result with a different technique?
If I can solve this I believe I can come up with a general algorithm
that can be used for various matrix-operations related to image
processing.
--
Olivier Chafik
+33 6 34 30 55 70
So "Hi Eivind", and thanks a lot for your suggestion on using while
loops vs for comprehensions :-)
The Seq/Array read/write methods are actually here for convenience,
not for speed (yet I still need to optimize them, notably with your
suggestion).
You should use the NIO buffer versions of read/write, if possible with
direct buffers (see directInts, directFloats... methods in
SyntaxUtils.scala)
Cheers
--
Olivier Chafik
+33 6 34 30 55 70
Le 12 oct. 2009 à 14:17, eivindw <eiv...@gmail.com> a écrit :