Recently I pushed a new version of the matrix manipulation package:

  http://github.com/raoulb/fricas_code/blob/master/mama/MAMA.spad
  http://github.com/raoulb/fricas_code/blob/master/mama/mama.input

There are still two small issues I'd like to resolve now.


I found that inside the following function, the list comprehension
works fine while the version using map does not:

    blockSplit(A:M, nr:PI, nc:PI) : List List M ==
      --map( (X:M):(List M) +-> horizSplit(X, nc), vertSplit(A, nr) )
      [ horizSplit(X, nc) for X in vertSplit(A, nr) ]  

where horizSplit and vertSplit have the declarations:

    horizSplit(A:M, c:PI) : List M   
    vertSplit(A:M, r:PI) : List M

I would think that the two do the same, but it does not seem so.
Why exactly? Do I need another import for map maybe?

Anyway, it fails with this error:

------------------------------------------------------------------
****** comp fails at level 2 with expression: ******
error in function blockSplit 

(|map| | << | (+-> (|:| (|:| X M) (|List| M)) (|horizSplit| X |nc|)) | >> |
 (|vertSplit| A |nr|))
****** level 2  ******
$x:= (+-> (: (: X M) (List M)) (horizSplit X nc))
$m:= (List M)
$f:=
((((|:| #) (|value| # #) (|nc| # #) (|nr| # #) ...)))
 
   >> Apparent user error:
   Cannot coerce (CONS (CLOSEDFN (LAMBDA (X $$) (PROG (nc $) (SETQ nc (QREFELT 
$$ 1)) (SETQ $ (QREFELT $$ 0)) (RETURN (PROGN (SPADCALL X nc (QREFELT $ 
71))))))) (VECTOR $ nc)) 
      of mode (Mapping (List M) M) 
      to mode (List M) 
------------------------------------------------------------------


The other part where I'm stuck is the function

    rows(A:M, si:SPI) : M

with SPI a Segment(PI). I thought that I can implement it by
forwarding to a call of "rows(A:M, lst:LPI) : M" with LST a List(PI)
via:

        rows(A, expand(si))

but this gives my an error:

------------------------------------------------------------------
****** comp fails at level 3 with expression: ******
error in function rows 

(|rows| A (|expand| | << si >> |))
****** level 3  ******
$x:= si
$m:= (List (Segment (PositiveInteger)))
$f:=
((((|si| # . #1=#) (A # #) (|si| . #1#) (= #) ...)))
 
   >> Apparent user error:
   Cannot coerce si 
      of mode (Segment (PositiveInteger)) 
      to mode (List (Segment (PositiveInteger))) 

------------------------------------------------------------------

There are two functions called expand for Segment:

)show Segment
 ...
 expand : % -> List(S) if S has ORDRING
 expand : List(%) -> List(S) if S has ORDRING
 ...

and my code would need the first one. Does the compiler try the
second one here? How could I force it to explicitly use the first?

Hmm, I see that:

(1) -> PI has ORDRING

   (1)  false

                                                                Type: Boolean
This means I can not expand a Segment(PI) into a List?
Why not, it seems to be a natural operation, no?

Because this can not work given that PI does not fulfill the requirements,
I tried something like:

      lp : LPI := [ i for i in si ]
      rows(A, lp)

writing out the "expand" in an explicit for loop. This again errors with:

------------------------------------------------------------------
****** comp fails at level 3 with expression: ******
error in function rows 

(SEQ
 (LET (|:| |lp| (|List| (|PositiveInteger|)))
   | << |
   (COLLECT (IN |i| |si|) |i|)
   | >> |)
 (|exit| 1 (|rows| A |lp|)))
****** level 3  ******
$x:= (COLLECT (IN i si) i)
$m:= $EmptyMode
$f:=
((((|lp| #) (|si| # . #1=#) (A # #) (|si| . #1#) ...)))
 
   >> Apparent user error:
   mode: 
   (Segment (PositiveInteger))
    must be a list of some mode
------------------------------------------------------------------


Note that all what fails here appeared to work in the interpreter ...
(I know there are substantial differences between compiler and
interpreter, but I'm not able to overcome them properly.)


Can you please give me some hints what's going on here
and how I can resolve the problems? Thanks.

-- 
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.

Attachment: mama.input
Description: Binary data

Attachment: MAMA.spad
Description: Binary data

Reply via email to