Carlos Aya wrote:
>..
>::UMatrix elemType = { rows :: !Int
>                     , cols :: !Int
>                     , vals :: ({#} elemType)
>                     }
>..
>The problem I am facing is update in place of the array vals, I want to have 
>the following function (from implementation)
>
>...........................
>// adds one matrix onto another (in place add)
>fAdd :: *(UMatrix elemType) (UMatrix elemType) -> *(UMatrix elemType) | Array 
>{#} elemType & Arith elemType
>fAdd m1 m2
>| sameSize m1 m2
>    # (arr, m1) = m1!vals   // <--- PROBLEM HERE
>    = {m1 & vals = updateInPlace arr f (size m2.vals)}
>= abort "Invalid matrix add"
>where
>    f v p = v + m2.vals.[p]
>..
>
>The problem is that updateInPlace expects a unique array, but the signature I 
>am getting in PROBLEM HERE is
>
>m1!vals :: ({#a}, u:(UMatrix v:a))
>
>i.e., the array inside the record is not unique (at least, this is how I 
>understand it).
>
>I have tried to define UMatrix with . and attribute variables in the hope that 
>it will change the signature of the record "!" operator, but with no luck. And 
>read the manual and the clean book but nothing said in b&w about the "!" 
>operator, at least for me as I couldn't link the whole concept of uniqueness 
>propagation for records.
>
>How can I extract the array from the unique parameter in fAdd and expect it to 
>be unique?

Add a . before the array type in the declaration of type UMatrix:

::UMatrix elemType = { rows :: !Int
                     , cols :: !Int
                     , vals :: . {#elemType}
                     }

this makes the array unique if the record is unique,

and do not try to use ! to extract unique elements. This doesn't work
because of a limitation in the reference analysis. Instead extract
the element using a pattern match or a selection with .

Kind regards,

John van Groningen
_______________________________________________
clean-list mailing list
[email protected]
http://mailman.science.ru.nl/mailman/listinfo/clean-list

Reply via email to