From: Guido Kanschat Date: Fri, 11 Mar 2005 15:12:27 +0000 (+0000) Subject: example for product matrix X-Git-Tag: v8.0.0~14435 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=059e87345b79cc7bd5785286bd25b3ce6b28f0fb;p=dealii.git example for product matrix git-svn-id: https://svn.dealii.org/trunk@10098 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/examples/doxygen/Makefile b/deal.II/examples/doxygen/Makefile index 0a8ac81139..ffd7c6d66f 100644 --- a/deal.II/examples/doxygen/Makefile +++ b/deal.II/examples/doxygen/Makefile @@ -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 index 0000000000..b6ffaa8da6 --- /dev/null +++ b/deal.II/examples/doxygen/product_matrix.cc @@ -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 +#include +#include +#include +#include + + +double Adata[] = +{ + .5, .1, + .4, .2 +}; + +double Bdata[] = +{ + .866, .5, + -.5, .866 +}; + + +int main() +{ + FullMatrix A(2,2); + FullMatrix B(2,2); + + A.fill(Adata); + B.fill(Bdata); + + GrowingVectorMemory > mem; + + ProductMatrix > AB(A,B,mem); + + Vector u(2); + Vector 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; +}