Go to the documentation of this file.00001
00002
00003
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef _CHOMP_HOMOLOGY_TABULATE_H_
00037 #define _CHOMP_HOMOLOGY_TABULATE_H_
00038
00039 #include "chomp/system/config.h"
00040 #include "chomp/system/textfile.h"
00041
00042 #include <iostream>
00043 #include <fstream>
00044 #include <cstdlib>
00045
00046 namespace chomp {
00047 namespace homology {
00048
00051 class Tabulated
00052 {
00053 public:
00055 Tabulated ();
00056
00058 ~Tabulated ();
00059
00061 int read (int dim, const char *filename);
00062
00064 int write (int dim, const char *filename) const;
00065
00067 int compute (int dim);
00068
00072 int define (int dim, char *buffer);
00073
00076 const char *operator [] (int dim) const;
00077
00079 static int get (const char *table, int_t bitnumber);
00080
00082 static void set (char *table, int_t bitnumber);
00083
00084 private:
00086 static const int maxdim = 8;
00087
00089 char *tables [maxdim];
00090
00092 bool deallocate [maxdim];
00093
00095 int size [maxdim];
00096
00097 };
00098
00099
00100
00101 inline int Tabulated::define (int dim, char *buffer)
00102 {
00103 if ((dim <= 0) || (dim >= maxdim))
00104 return -1;
00105 if (tables [dim] && deallocate [dim])
00106 {
00107 delete [] (tables [dim]);
00108 deallocate [dim] = false;
00109 }
00110 tables [dim] = buffer;
00111 return 0;
00112 }
00113
00114 inline const char *Tabulated::operator [] (int dim) const
00115 {
00116 if ((dim <= 0) || (dim >= maxdim))
00117 return 0;
00118 else
00119 return tables [dim];
00120 }
00121
00122 inline int Tabulated::get (const char *table, int_t bitnumber)
00123 {
00124 if (table [bitnumber >> 3] & (1 << (bitnumber & 0x07)))
00125 return 1;
00126 else
00127 return 0;
00128 }
00129
00130 inline void Tabulated::set (char *table, int_t bitnumber)
00131 {
00132 table [bitnumber >> 3] |=
00133 static_cast<char> (1 << (bitnumber & 0x07));
00134 return;
00135 }
00136
00137
00138
00141 extern Tabulated tabulated;
00142
00143
00144 }
00145 }
00146
00147 #endif // _CHOMP_HOMOLOGY_TABULATE_H_
00148
00150