]> https://gitweb.dealii.org/ - dealii.git/commitdiff
example for product matrix
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 11 Mar 2005 15:12:27 +0000 (15:12 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Fri, 11 Mar 2005 15:12:27 +0000 (15:12 +0000)
git-svn-id: https://svn.dealii.org/trunk@10098 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/examples/doxygen/Makefile
deal.II/examples/doxygen/product_matrix.cc [new file with mode: 0644]

index 0a8ac8113987112af03f301ded21a37f401b37c3..ffd7c6d66fd84afe66b4cf308aeb6e452638cf80 100644 (file)
@@ -12,7 +12,7 @@
 ###########################################################################
 include ../../common/Make.global_options
 
-all: block_matrix_array.exe
+all: product_matrix.exe block_matrix_array.exe
 
 ######################################################################
 # Compilation of source code
@@ -30,7 +30,9 @@ block_matrix_array.exe: block_matrix_array.o $(lib-base.g) $(lib-lac.g)
        @echo =====linking====$(MT)== $<
        @$(CXX) $(CXXFLAGS.g) $(LDFLAGS) -o $@ $^
 
-
+product_matrix.exe: product_matrix.o $(lib-base.g) $(lib-lac.g)
+       @echo =====linking====$(MT)== $<
+       @$(CXX) $(CXXFLAGS.g) $(LDFLAGS) -o $@ $^
 
 ######################################################################
 # Pseudo target for cleaning directory
diff --git a/deal.II/examples/doxygen/product_matrix.cc b/deal.II/examples/doxygen/product_matrix.cc
new file mode 100644 (file)
index 0000000..b6ffaa8
--- /dev/null
@@ -0,0 +1,61 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//---------------------------------------------------------------------------
+
+// See documentation of Product for documentation of this example
+
+#include <base/logstream.h>
+#include <lac/matrix_lib.h>
+#include <lac/full_matrix.h>
+#include <lac/vector.h>
+#include <lac/vector_memory.h>
+
+
+double Adata[] =
+{
+      .5, .1,
+      .4, .2
+};
+
+double Bdata[] =
+{
+      .866, .5,
+      -.5, .866
+};
+
+
+int main()
+{
+  FullMatrix<float> A(2,2);
+  FullMatrix<double> B(2,2);
+
+  A.fill(Adata);
+  B.fill(Bdata);
+  
+  GrowingVectorMemory<Vector<double> > mem;
+  
+  ProductMatrix<Vector<double> > AB(A,B,mem);
+
+  Vector<double> u(2);
+  Vector<double> v(2);
+
+  u(0) = 1.;
+  u(1) = 2.;
+
+  AB.vmult(v,u);
+
+  deallog << v(0) << '\t' << v(1) << std::endl;
+
+  AB.Tvmult(v,u);
+
+  deallog << v(0) << '\t' << v(1) << std::endl;
+}

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.