]> www.ginac.de Git - ginac.git/blobdiff - ginsh/ginsh_parser.yy
- dramatic speedup for characteristic polynomials of numerical matrices.
[ginac.git] / ginsh / ginsh_parser.yy
index 6931d18944f3d64dbada3089b77723bb17db51fe..8538ad0bcf192b2d511be73f485188e703900d81 100644 (file)
@@ -1,8 +1,9 @@
 /** @file ginsh_parser.yy
  *
  *  Input grammar definition for ginsh.
- *  This file must be processed with yacc/bison.
- *
+ *  This file must be processed with yacc/bison. */
+
+/*
  *  GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -39,6 +40,8 @@
 
 #include "ginsh.h"
 
+#define YYERROR_VERBOSE 1
+
 // Original readline settings
 static int orig_completion_append_character;
 static char *orig_basic_word_break_characters;
@@ -77,8 +80,6 @@ static help_tab help;
 
 static void print_help(const string &topic);
 static void print_help_topics(void);
-
-static ex lst2matrix(const ex &l);
 %}
 
 /* Tokens (T_LITERAL means a literal value returned by the parser, but not
@@ -206,7 +207,7 @@ exp : T_NUMBER              {$$ = $1;}
        | exp '!'               {$$ = factorial($1);}
        | '(' exp ')'           {$$ = $2;}
        | '[' list_or_empty ']' {$$ = $2;}
-       | T_MATRIX_BEGIN matrix T_MATRIX_END    {$$ = lst2matrix($2);}
+       | T_MATRIX_BEGIN matrix T_MATRIX_END    {$$ = lst_to_matrix($2);}
        ;
 
 exprseq        : exp                   {$$ = exprseq($1);}
@@ -653,33 +654,6 @@ static void print_help_topics(void)
 }
 
 
-/*
- *  Convert list of lists to matrix
- */
-
-static ex lst2matrix(const ex &l)
-{
-       if (!is_ex_of_type(l, lst))
-               throw(std::logic_error("internal error: argument to lst2matrix() is not a list"));
-
-       // Find number of rows and columns
-       unsigned rows = l.nops(), cols = 0, i, j;
-       for (i=0; i<rows; i++)
-               if (l.op(i).nops() > cols)
-                       cols = l.op(i).nops();
-
-       // Allocate and fill matrix
-       matrix &m = *new matrix(rows, cols);
-       for (i=0; i<rows; i++)
-               for (j=0; j<cols; j++)
-                       if (l.op(i).nops() > j)
-                               m.set(i, j, l.op(i).op(j));
-                       else
-                               m.set(i, j, ex(0));
-       return m;
-}
-
-
 /*
  *  Function name completion functions for readline
  */
@@ -733,6 +707,7 @@ void greeting(void)
 /*
  *  Main program
  */
+
 int main(int argc, char **argv)
 {
        // Print banner in interactive mode
@@ -758,13 +733,14 @@ int main(int argc, char **argv)
        insert_fcn_help("atan", "inverse tangent function");
        insert_fcn_help("atan2", "inverse tangent function with two arguments");
        insert_fcn_help("atanh", "inverse hyperbolic tangent function");
-       insert_fcn_help("Beta", "Beta function");
+       insert_fcn_help("beta", "Beta function");
        insert_fcn_help("binomial", "binomial function");
        insert_fcn_help("cos", "cosine function");
        insert_fcn_help("cosh", "hyperbolic cosine function");
        insert_fcn_help("exp", "exponential function");
        insert_fcn_help("factorial", "factorial function");
-       insert_fcn_help("Gamma", "Gamma function");
+       insert_fcn_help("lgamma", "natural logarithm of Gamma function");
+       insert_fcn_help("tgamma", "Gamma function");
        insert_fcn_help("log", "natural logarithm");
        insert_fcn_help("psi", "psi function\npsi(x) is the digamma function, psi(n,x) the nth polygamma function");
        insert_fcn_help("sin", "sine function");