]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
check new arithmetic functions
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 16 Dec 2003 11:29:22 +0000 (11:29 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 16 Dec 2003 11:29:22 +0000 (11:29 +0000)
git-svn-id: https://svn.dealii.org/trunk@8268 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/polynomial1d.cc
tests/results/i686-pc-linux-gnu+gcc3.2/base/polynomial1d.output

index 3e482385351c0b9776b660136946385d299ab0d3..303775f7dfb5a2c6dc934e79decbc302d248ca9a 100644 (file)
@@ -44,13 +44,58 @@ double scalar_product (const Polynomial<double>& p1,
   return sum;
 }
 
+
+void polynomial_arithmetic ()
+{
+  std::vector<double> c1(4);
+  c1[0] = 2;
+  c1[1] = 3;
+  c1[2] = 5;
+  c1[3] = 4;
+  Polynomial<double> p1(c1);
+  
+  std::vector<double> c2(3);
+  c2[0] = .4;
+  c2[1] = .7;
+  c2[2] = -1.3;
+  Polynomial<double> p2(c2);
+  Monomial<double> p3(5);
+  std::cerr << "P1" << std::endl;
+  p1.print(std::cerr);
+  std::cerr << "P2" << std::endl;
+  p2.print(std::cerr);
+  p1 += p2;
+  std::cerr << "P1+P2" << std::endl;
+  p1.print(std::cerr);
+  p2 += p1;
+  std::cerr << "P1+2P2" << std::endl;
+  p2.print(std::cerr);
+  std::cerr << "P1+P2+x^5" << std::endl;
+  p1 += p3;
+  p1.print(std::cerr);
+  p1 *= 2.;
+  std::cerr << "*2" << std::endl;
+  p1.print(std::cerr);
+  
+  for (unsigned int i=0;i<7;++i)
+    {
+      std::cerr << "derive" << std::endl;
+      p1 = p1.derivative();
+      p1.print(std::cerr);
+    }
+}
+
+
 int main ()
 {
   std::ofstream logfile("polynomial1d.output");
   logfile.precision(3);
   deallog.attach(logfile);
   deallog.depth_console(0);
+  deallog.log_cerr();
 
+  polynomial_arithmetic();
+  
   std::vector<Polynomial<double> > p;
   std::vector<Polynomial<double> > q;
 
index 9920cfa1f69598012bb480bc7c243ebaa09c77bb..4c206742887f96a106f6e3e05826d6c16466f605 100644 (file)
@@ -1,4 +1,61 @@
 
+P1
+4.00000 x^3
+5.00000 x^2
+3.00000 x^1
+2.00000 x^0
+P2
+-1.30000 x^2
+0.700000 x^1
+0.400000 x^0
+P1+P2
+4.00000 x^3
+3.70000 x^2
+3.70000 x^1
+2.40000 x^0
+P1+2P2
+4.00000 x^3
+2.40000 x^2
+4.40000 x^1
+2.80000 x^0
+P1+P2+x^5
+1.00000 x^5
+0.00000 x^4
+4.00000 x^3
+3.70000 x^2
+3.70000 x^1
+2.40000 x^0
+*2
+2.00000 x^5
+0.00000 x^4
+8.00000 x^3
+7.40000 x^2
+7.40000 x^1
+4.80000 x^0
+derive
+10.0000 x^4
+0.00000 x^3
+24.0000 x^2
+14.8000 x^1
+7.40000 x^0
+derive
+40.0000 x^3
+0.00000 x^2
+48.0000 x^1
+14.8000 x^0
+derive
+120.000 x^2
+0.00000 x^1
+48.0000 x^0
+derive
+240.000 x^1
+0.00000 x^0
+derive
+240.000 x^0
+derive
+0.00000 x^0
+derive
+0.00000 x^0
 DEAL::Legendre
 DEAL::P0 * P0 =1.00
 DEAL::P1 * P0 =0.00

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.