homology.h

Go to the documentation of this file.
00001 
00002 
00003 
00016 
00017 // Copyright (C) 1997-2010 by Pawel Pilarczyk.
00018 //
00019 // This file constitutes a part of the Homology Library, 
00020 // distributed under the terms of the GNU General Public License.
00021 // Consult  http://capd.wsb-nlu.edu.pl/ for details. 
00022 
00023 // Started on March 19, 2006. Last revision: July 27, 2007.
00024 
00025 
00026 #ifndef _CAPD_HOMENGIN_HOMOLOGY_H_ 
00027 #define _CAPD_HOMENGIN_HOMOLOGY_H_ 
00028 
00029 #include <string>
00030 #include <cstring>
00031 #include "capd/homengin/engines.h"
00032 
00033 
00053 inline void ComputeBettiNumbers (const void *buffer, int *sizes, int dim,
00054         int *result, const char *engine = 0, const int *wrapping = 0,
00055         bool quiet = false)
00056 {
00057         using namespace chomp::homology;
00058         // turn off screen output if requested to
00059         bool soutput = sout. show;
00060         bool coutput = scon. show;
00061         if (quiet)
00062         {
00063                 sout. show = false;
00064                 scon. show = false;
00065                 fcout. turnOff ();
00066         }
00067         else
00068                 fcout. turnOn ();
00069 
00070         // create a corresponding set of cubes
00071         chomp::homengin::cubitmap X (reinterpret_cast<const char *> (buffer),
00072                 sizes, dim);
00073 
00074         // set the space wrapping
00075         if (wrapping)
00076                 X. setwrapping (wrapping, dim);
00077 
00078         // find the best engine to use for the homology computation
00079         const chomp::homengin::engine *e;
00080         if (!engine)
00081                 e = chomp::homengin::engine::find (&X);
00082 
00083         // another possibility: find the engine with the given name
00084         else
00085                 e = chomp::homengin::engine::find (engine);
00086 
00087         // compute the homology of the set of cubes
00088         chomp::homengin::algstruct<chomp::homology::integer> hom;
00089         e -> homology (X, hom);
00090         sout << "The computed homology is " << hom << ".\n";
00091 
00092         // fill in the resulting table of Betti numbers
00093         int levels = hom. countLevels ();
00094         for (int i = 0; i <= dim; ++ i)
00095                 result [i] = (i < levels) ? hom. getBetti (i) : 0;
00096 
00097         // restore the message settings
00098         chomp::homology::sout. show = soutput;
00099         chomp::homology::scon. show = coutput;
00100         return;
00101 } /* ComputeBettiNumbers */
00102 
00103 
00104 // *** temporarily ***
00105 #include "capd/homengin/cubiset.h"
00106 
00107 
00108 #endif // _CAPD_HOMENGIN_HOMOLOGY_H_ 
00109 
00111