basix_doc 0.1
generic_test.cpp
/******************************************************************************
* MODULE     : generic_test.cc
* DESCRIPTION: Test generic expressions
* COPYRIGHT  : (C) 2003  Joris van der Hoeven
*******************************************************************************
* This software falls under the GNU general public license and comes WITHOUT
* ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
* If you don't have this file, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/

#include <basix/lisp_syntax.hpp>
#include <basix/port.hpp>
using namespace mmx;

int
main () {
  generic f ("f");
  generic x ("x");
  generic y ("y");
  generic z= f (x, y);
  generic t= xsqtuple (comma (comma (x, x), comma (y, z)));
  generic u= parse_lisp ("(+ (f x x) (g (^ x x)))");

  mmout << "x\t= " << x << "\n";
  mmout << "y\t= " << y << "\n";
  mmout << "z\t= " << z << "\n";
  mmout << "t\t= " << t << "\n";
  mmout << "u\t= " << u << "\n\n";

  mmout << "x=y\t= " << (x==y) << "\n";
  mmout << "x!=y\t= " << (x!=y) << "\n";
  mmout << "z=z\t= " << (z==z) << "\n";
  mmout << "x=z\t= " << (x==z) << "\n";
  mmout << "x*y\t= " << (x*y) << "\n";
  mmout << "x+1\t= " << (x+1) << "\n";
  mmout << "x+0\t= " << (x+0) << "\n";
  mmout << "z*z\t= " << z*z << "\n";
  mmout << "z*z*z\t= " << z*z*z << "\n";
  mmout << "z/7\t= " << z/7 << "\n";
  mmout << "z/111\t= " << z/111 << "\n\n";

  mmout << "x x\t\t\t= " << x*x << "\n";
  mmout << "2 x y\t\t\t= " << 2*x*y << "\n";
  mmout << "2 x y + y x\t\t= " << 2*x*y + y*x << "\n";
  mmout << "2 x y + x y\t\t= " << 2*x*y + x*y << "\n";
  mmout << "2 x y - y x\t\t= " << 2*x*y - y*x << "\n";
  mmout << "2 x y - y x - x y\t= " << 2*x*y - y*x - x*y << "\n";
  mmout << "x (x + y)\t\t= " << x*(x+y) << "\n";
  mmout << "(x + y) (x - y)\t\t= " << (x+y) * (x-y) << "\n";
  mmout << "2 (x + y) - x\t\t= " << 2*(x+y) - x << "\n\n";

  mmout << "x x / x\t\t\t= " << x*x/x << "\n";
  mmout << "(x^2)^3\t\t\t= " << pow (pow (x, generic(2)), generic(3)) << "\n";
  mmout << "(x^x)^y\t\t\t= " << pow (pow (x, x), y) << "\n";
  mmout << "(x y)^y\t\t\t= " << pow (x*y, y) << "\n";
  mmout << "(x y)^y / x\t\t= " << pow (x*y, y) / x << "\n";
  mmout << "(x y)^y / (x y)\t\t= " << pow (x*y, y) / (x*y) << "\n";
  mmout << "(x y)^y / (x y)^2\t= " << pow(x*y,y) / pow(x*y,generic(2)) << "\n";
  mmout << "((x + y)^x)^y\t\t= " << pow (pow (x+y, x), y) << "\n";

  return 0;
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines