algebramix_doc 0.3
fkt_test.cpp
/******************************************************************************
* MODULE     : fkt_test.cc
* DESCRIPTION: Test "fast Karatsuba transforms"
* COPYRIGHT  : (C) 2006  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 <numerix/rational.hpp>
#include <algebramix/fkt_transform.hpp>
using namespace mmx;

#define C rational
#define Vec implementation<vector_linear,vector_naive>
#define Fkt fkt_package<polynomial_naive>

int
main () {
  /*
  C buf_f[3]; buf_f[0]= 1; buf_f[1]= 2;
  C buf_g[3]; buf_g[0]= 3; buf_g[1]= 4;
  mmout << "f: "; Vec::print (mmout, buf_f, 2); mmout << "\n";
  mmout << "g: "; Vec::print (mmout, buf_g, 2); mmout << "\n";
  Fkt::direct_fkt (buf_f, 2, 3);
  Fkt::direct_fkt (buf_g, 2, 3);
  mmout << "Kf: "; Vec::print (mmout, buf_f, 3); mmout << "\n";
  mmout << "Kg: "; Vec::print (mmout, buf_g, 3); mmout << "\n";
  C buf_h[3];
  for (nat i=0; i<3; i++) buf_h[i]= buf_f[i] * buf_g[i];
  mmout << "Kh: "; Vec::print (mmout, buf_h, 3); mmout << "\n";
  Fkt::inverse_fkt (buf_h, 3, 2);
  mmout << "h: "; Vec::print (mmout, buf_h, 3); mmout << "\n";
  */

  C buf_f[9]; buf_f[0]= 1; buf_f[1]= 2; buf_f[2]= 3; buf_f[3]= 4;
  C buf_g[9]; buf_g[0]= 3; buf_g[1]= 4; buf_g[2]= 0; buf_g[3]= 1;
  mmout << "f: "; Vec::print (mmout, buf_f, 4); mmout << "\n";
  mmout << "g: "; Vec::print (mmout, buf_g, 4); mmout << "\n";
  Fkt::direct_fkt (buf_f, 4, 9);
  Fkt::direct_fkt (buf_g, 4, 9);
  mmout << "Kf: "; Vec::print (mmout, buf_f, 9); mmout << "\n";
  mmout << "Kg: "; Vec::print (mmout, buf_g, 9); mmout << "\n";
  C buf_h[9];
  for (nat i=0; i<9; i++) buf_h[i]= buf_f[i] * buf_g[i];
  mmout << "Kh: "; Vec::print (mmout, buf_h, 9); mmout << "\n";
  Fkt::inverse_fkt (buf_h, 9, 4);
  mmout << "h: "; Vec::print (mmout, buf_h, 7); mmout << "\n";

  /*
  C buf_f[27]; for (nat i=0; i<8; i++) buf_f[i]= 1;
  C buf_g[27]; for (nat i=0; i<8; i++) buf_g[i]= 1;
  mmout << "f: "; Vec::print (mmout, buf_f, 8); mmout << "\n";
  mmout << "g: "; Vec::print (mmout, buf_g, 8); mmout << "\n";
  Fkt::direct_fkt (buf_f, 8, 27);
  Fkt::direct_fkt (buf_g, 8, 27);
  mmout << "Kf: "; Vec::print (mmout, buf_f, 27); mmout << "\n";
  mmout << "Kg: "; Vec::print (mmout, buf_g, 27); mmout << "\n";
  C buf_h[27];
  for (nat i=0; i<27; i++) buf_h[i]= buf_f[i] * buf_g[i];
  mmout << "Kh: "; Vec::print (mmout, buf_h, 27); mmout << "\n";
  Fkt::inverse_fkt (buf_h, 27, 8);
  mmout << "h: "; Vec::print (mmout, buf_h, 15); mmout << "\n";
  */

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