> >> cumSum(l: List Integer): List Integer == (s:=0;[(s:=s+i) for i in
> >> l])

BTW: Why can I not use this for List PI?

   >> Apparent user error:
   Cannot coerce lc 
      of mode (List (PositiveInteger)) 
      to mode (List (Integer))

The other way round would make sense for me.
But PI is a subset (and subtype) of INT ...
What am I missing again? These errors are not
so apparent for me ;-)

> > I think it is not so user friendly to type this line every time one
> > needs that function.
> 
> Well, the question is always, how often that function will be used
> later, i.e. how many users would find that useful.

As usual ... but I'm not sure if this really matters for
small convenience functions? They are unlikely to introduce
a bug or cause much work in the future I'd say.

> Could you also explain why you see this function as usefull?

For going from a list of differences to the list of terms.
This can be useful in any counting context. For me it will
be to go from a list of block sizes to the list of row/col
indices.

It's just something I would say is nice to have in the
more functional context.

Right now I don't have a really strong argument though.


> https://github.com/raoulb/fricas_code/blob/master/mama/MAMA.spad#L33
> 
>     element(A, r, c) ==
>       matrix([[A(r,c)]])
> 
> It just puts the result of A(r,c) into a 1x1 matrix. What's the gain?

The gain is that this plays well with the construction of block
matrices. Sometimes we have single numbers/entries in a corner
or similar. Ideally it would not be necessary, but we are not
at that point yet.

We would need blockConcat( List(List(Matrix(R) or R) ) and
a careful implementation of that function. (I think Union
is the construct to use.) Maybe I should try.

Anyway, I think there are situations where interpreting
a value e as matrix([[e]]) can make sense.

>     arow(A:M, r:PI) : M ==
>       -- Really not happy with this:
>       transpose(row(A pretend Matrix(R), r)::Matrix(R)) pretend M
> 
> I also don't get, why you are unhappy with that?

Because it feels wrong ;-)
To much type stuff in that line.

> You can probably write
> 
>    transpose(row(A, r)::Matrix(R)) pretend M

No, I tried that, the error is:

   >> Apparent user error:
   Cannot coerce (call (ELT $ 16) A r) 
      of mode Row 
      to mode (Matrix R) 

> Now, it becomes clearer, why this is dangerous.

> 1) in Matrix R there is a coerce from Vector R to Matrix R. But since
> A:M, we have row(A): Row. Where do you see that Row and Vector(R) are
> compatible? In fact the compiler should not let you compile this code.
> 
> Furthermore, the final "pretend M" is dangerous as well. It is by no
> means clear that Matrix R and M would have the same representation.

And that are the reasons why I'm not happy with it. I'm telling
the compiler stuff I don't even know by myself!

It was just the only way I could find to make it working
in the first place, given my limited knowledge on types
and coercion.

On the other hand, there must be a way to extract parts of
a matrix and interpret the parts again as matrices, possible
with only a single row or column. 

Thinking about it now, maybe I should just use subMatrix:

  arow(A:M, r:PI) : M ==
    subMatrix(A, r, r, minc A, maxc A)

Thanks for making me retry ... I was on the wrong path.

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to