fricas in batch mode....

11 views
Skip to first unread message

Sid Andal

unread,
Nov 23, 2021, 12:50:46 PM11/23/21
to fricas...@googlegroups.com
Tried running the fricas in batch mode as following:

fricas -nosman < file.input > file.out

solving many linear-systems of equations. The file.out listed the solution vectors one per line (with separating blank lines).
However, the solutions were then followed with system messages and their line numbers till the end of the file.out.

Is there a way to suppress all messages (complete silent mode) and output only the solutions?

Thanks. Regards

SWA

Ralf Hemmecke

unread,
Nov 23, 2021, 1:15:02 PM11/23/21
to fricas...@googlegroups.com
> Tried running the fricas in batch mode as following:

> fricas -nosman < file.input > file.out

I remember that I used something like

echo ")read file.input" | fricas -nosman > file.out

But that changes only whether the input commands will be printed or not.

> Is there a way to suppress all messages (complete silent mode) and output
> only the solutions?

Not that I know.

However, the results in the FriCAS-book are generated using a little
trick. It uses ioHook to print something before and after the output. In
that way you can easily single out the stuff that you actually want.

If you do not need 2d output, you can also try

(202) -> setFormat!(Format1D)$JFriCASSupport

(204) n + a
--FORMAT:BEG:Format1D
n^r+a
--FORMAT:END:Format1D

Switch that output off via

)set output formatted off

Oh, but maybe it could help if you simply do


)set output algebra off
some computation commands
)set output algebra on
your output command
END_OF_INPUT_FILE

Let me know what helps.

Ralf

Sid Andal

unread,
Nov 23, 2021, 2:35:42 PM11/23/21
to FriCAS - computer algebra system
Tried the suggested output format settings and the system-generated messages still appeared following the solutions. I'm not sure why the "write!" function is so rigid and inflexible not allowing some basic formatting....!

Ralf Hemmecke

unread,
Nov 23, 2021, 2:40:46 PM11/23/21
to fricas...@googlegroups.com
> Tried the suggested output format settings and the system-generated
> messages still appeared following the solutions. I'm not sure why the
> "write!" function is so rigid and inflexible not allowing some basic
> formatting....!

Sorry to say, but you have not given any input and no exact
specification of what you want to get out. With so few information I am
unable to give any further advice.

Ralf

Sid Andal

unread,
Nov 23, 2021, 2:48:31 PM11/23/21
to FriCAS - computer algebra system
Here's a sample of the file.input:


****BEG OF file.input****
F := IPF 19;
fp : File List F := open("file.out", "output");
x := (solve([[1,13,14,15],[1,11,18,4],[1,14,10,4],[1,6,17,16]] :: SquareMatrix(4, F),[13,8,6,14] :: Vector F)).particular;
if x case "failed" then x := [0,0,0,0];
write!(fp,x);
x := (solve([[17,13,14,15],[17,11,18,4],[17,14,10,4],[17,6,17,16]] :: SquareMatrix(4, F),[13,8,6,14] :: Vector F)).particular;
if x case "failed" then x := [0,0,0,0];
write!(fp,x);
x := (solve([[2,13,0,7],[15,7,6,13],[11,0,14,2],[12,3,2,10]] :: SquareMatrix(4, F),[15,15,4,12] :: Vector F)).particular;
if x case "failed" then x := [0,0,0,0];
write!(fp,x);
x := (solve([[14,3,12,15],[11,15,0,14],[17,16,1,13],[4,5,15,17]] :: SquareMatrix(4, F),[10,10,12,6] :: Vector F)).particular;
if x case "failed" then x := [0,0,0,0];
write!(fp,x);
x := (solve([[3,8,10,2],[8,14,16,0],[9,5,12,14],[5,2,1,5]] :: SquareMatrix(4, F),[15,8,11,3] :: Vector F)).particular;
if x case "failed" then x := [0,0,0,0];
write!(fp,x);
)sys sleep 1
close! (fp);
****END OF file.input****


And the file.out:


****BEG OF file.out****

(5 8 8 14)


(7 8 8 14)


(18 12 1 10)


(9 15 11 2)


(18 2 4 0)


(4) -> (4) ->
(5) -> (6) -> (6) ->
(7) -> (7) ->
(8) -> (9) -> (9) ->
(10) -> (10) ->
(11) -> (12) -> (12) ->
(13) -> (13) ->
(14) -> (15) -> (15) ->
(16) -> (16) ->
(17) -> (18) -> (18) ->
(19) -> (19) -> (19) ->
(20) ->
****END OF file.out****

Ralf Hemmecke

unread,
Nov 23, 2021, 3:05:22 PM11/23/21
to fricas...@googlegroups.com
On 23.11.21 20:48, Sid Andal wrote:
> Here's a sample of the file.input:
> And the file.out:

OK. And what do you actually want as output?
Would you be accept a little shell or perl script to work on the output?

In fact, when I run

fricas -nosman < file.input

then file.out is

hemmecke:~/scratch/sid>cat file.out

(5 8 8 14)


(7 8 8 14)


(18 12 1 10)


(9 15 11 2)


(18 2 4 0)


Isn't that what you want?

Ralf

Sid Andal

unread,
Nov 23, 2021, 3:13:55 PM11/23/21
to FriCAS - computer algebra system
When I run the "fricas -nosman < file.input" I get the above output (the sol vectors) and the extra stuff at the end; those numbers in parenthesizes and arrows.

Ralf Hemmecke

unread,
Nov 23, 2021, 3:28:11 PM11/23/21
to fricas...@googlegroups.com
> When I run the "fricas -nosman < file.input" I get the above output (the
> sol vectors) and the extra stuff at the end; those numbers in parenthesizes
> and arrows.

Are you sure? Note that I run

fricas -nosman < file.input

and you actually run

fricas -nosman < file.input > file.out

This is at least what you wrote in the first place.
The sleep command is unnecessary.

Ralf

I've shortened you input file a bit... ;-) See attachement.
sid.input

Sid Andal

unread,
Nov 23, 2021, 3:47:05 PM11/23/21
to FriCAS - computer algebra system
When I try to run the code from the attachment I get the following error:


fricas -nosman < file.input
Checking for foreign routines
FRICAS="/usr/local/lib/fricas/target/x86_64-linux-gnu"
spad-lib="/usr/local/lib/fricas/target/x86_64-linux-gnu/lib/libspad.so"
foreign routines found
openServer result -2
                       FriCAS Computer Algebra System
                            Version: FriCAS 1.3.7
                  Timestamp: Tue Jun 29 23:06:33 CEST 2021
-----------------------------------------------------------------------------
   Issue )copyright to view copyright notices.
   Issue )summary for a summary of useful system commands.
   Issue )quit to leave FriCAS and return to shell.
-----------------------------------------------------------------------------
 
(1) ->
(2) -> (2) ->   Line   1: wsol(fp, a, b) == (_
  Line   2:   x := (solve(a :: SquareMatrix(4, F), b::Vector(F)).particular;
           ...............................................................A
  Error  A: syntax error at top level
  Error  A: Improper syntax.
   2 error(s) parsing

(2) ->   Line   1:   if x case "failed" then vector [0,0,0,0] else x::Vector(F))
           ............................................................A
  Error  A: Improper syntax.
   1 error(s) parsing

(2) -> (2) ->
(3) -> (3) ->    There are no library operations named wsol
      Use HyperDoc Browse or issue
                                )what op wsol
      to learn if there is any operation containing " wsol " in its
      name.
 
   Cannot find a definition or applicable library operation named wsol
      with argument type(s)
                         File(List(PrimeField(19)))
                         List(List(PositiveInteger))
                            List(PositiveInteger)
     
      Perhaps you should use "@" to indicate the required return type,
      or "$" to specify which version of the function you need.

(3) ->    There are no library operations named wsol
      Use HyperDoc Browse or issue
                                )what op wsol
      to learn if there is any operation containing " wsol " in its
      name.
....

Sid Andal

unread,
Nov 23, 2021, 4:01:50 PM11/23/21
to FriCAS - computer algebra system
seems to be working with the following line:

fricas -nosman < file.input > /dev/null

then the file.out contains only the solutions and the extra stuff (system msgs) go /dev/null.

Ralf Hemmecke

unread,
Nov 23, 2021, 4:14:22 PM11/23/21
to fricas...@googlegroups.com
On 23.11.21 21:47, Sid Andal wrote:
> When I try to run the code from the attachment I get the following
> error:

Oh, I am sorry. My editor still held an unsaved version.

> seems to be working with the following line:
>
> fricas -nosman < file.input > /dev/null
>
> then the file.out contains only the solutions and the extra stuff
> (system msgs) go /dev/null.

You should understand, that output is completely done via fricas' write!
command.

What comes out of

fricas -nosman < file.input

goes to stdout or to /dev/null when you redirect it. But the latter is
completely irrelevant to file.out UNLESS you redirect to file.out.

Ralf
sid.input

Sid Andal

unread,
Nov 23, 2021, 4:30:24 PM11/23/21
to FriCAS - computer algebra system
Thanks....all is good now!
Reply all
Reply to author
Forward
0 new messages