penguian / glucat Goto Github PK
View Code? Open in Web Editor NEWGluCat: Clifford algebra templates
Home Page: http://glucat.sourceforge.net/
License: Other
GluCat: Clifford algebra templates
Home Page: http://glucat.sourceforge.net/
License: Other
Intel now has an icpx C++ compiler based on Clang, as well as icpc, which it now calls "Classic". Bring the configuration and build system up to date to support these as well as current GCC and Clang compilers. Check backward compatibility.
Try making Tune_P into a policy class template parameter.
The C++ headers need to be modernized to at least C++11. Use a tool like Clang Tidy to do this.
Make minimal changes to the code, and some changes to the configuration, so that Glucat and PyClical compile and work with current Boost, Numeric Bindings, and QD, and compile with current GCC, Clang and Intel compilers.
Ensure that the C++ code, Python, Markdown and Doxygen documentation work with current versions of these tools.
The clifford_algebra
template class has an isnan
member function, which returns true
if the coefficient of any term is NaN
as per traits_t::isNaN
. Add the corresponding isinf
member function using traits_t::isInf
.
PyClical and its tutorials and demonstrations currently target Python 2.7. Python 2 is no longer supported. Use all necessary tools to migrate all Cython and Python files and associated setup, build, make files, etc. to Python 3.
Ensure that numeric_traits<Scalar_T>::promoted::type
always has at least as many mantissa bits as Scalar_T
, and numeric_traits<Scalar_T>::demoted::type
has at most as many mantissa bits as Scalar_T
.
See https://en.cppreference.com/w/cpp/language/types . The C++ float
and double
types are usually based on the IEEE 754 32 bit and 64 bit floating point standards. In contrast, the long double
type can be anywhere from 64 bits (as IEEE 754 64 bit floating point) to 128 bits (as IEEE 754 128 bit floating point). The 128 bit format has a precision of 113 bits, but the dd_real
format has a precision of only 106 bits.
If long double
has the same number of mantissa bits as double
, promote as: float -> double -> dd_real -> qd_real
, long double -> dd_real
, and demote as: qd_real -> dd_real -> double -> float
, long double -> float
.
If long double
has more mantissa bits than dd_real
, promote as: float -> double -> dd_real -> long double -> qd_real
, and demote as: qd_real -> long double -> dd_real -> double -> float
.
Otherwise, continue to promote as: float -> double -> long double -> dd_real -> qd_real
, and demote as: qd_real -> dd_real -> long double -> double -> float
.
Rather than having a single default truncation for all multivector classes, make it depend on the scalar type. Specifically, set the default truncation as follows:
default_truncation = std::numeric_limits<Scalar_T>::epsilon()
framed_multi
to matrix_multi
, use default truncation on the framed_multi
input.matrix_multi
to framed_multi
, use default truncation on the framed_multi
output.GluCat uses uBLAS for linear algebra, except for finding eigenvalues, where it uses Boost Bindings. The two different libraries uses different matrix formats. Also, uBLAS is quite slow, especially for algorithms such as the addition of compressed matrices. Perhaps Armadillo would be better?
GluCat uses uBLAS for linear algebra, except for finding eigenvalues, where it uses Boost Bindings. The two different libraries use different matrix formats. Also, uBLAS is quite slow, especially for algorithms such as the addition of compressed matrices. Perhaps Blaze would be better?
The following options to ./configure
are essentially superceded and should be deprecated for the next release (0.10.1 ?) and removed in the following release, with an accompanying simplification of the source code.
--enable-check-isnan check for NaN values at various places in the code [default=yes]
In practice, this type of checking has not slowed execution speed by much. Also, the code now also checks for Inf
in various places and it its not clear how this option should be changed to cope with check for Inf
. The option should be removed, and the checks for Inf
and NaN
should always be performed.
--with-stdlib[=ARG] C++ standard library to use
(libcxx|libstdcxx)
[default=libstdcxx]
This option is currently applied only to Clang++ and only when the option libcxx
is chosen. The default for recent Clang++ versions is to use libc++
rather than libstdc++
. In other words, contrary to the INSTALL
documentation, this option has no effect. It is not clear at this stage what value would be added by allowing Clang++ to use libstdc++
. The option should be removed, since it has no effect anyway.
--with-map[=ARG] type of map to use
(map|stdunordered)
[default=stdunordered]
In practice, the hash function used with famed_multi
has worked reasonably well, and has been asymptotically faster than just using std::map
. The option should be removed, and std::unordered_map
should always be used, with the exception of cases where ordering is needed, such as printing.
--with-pool-alloc use Boost Pool allocator
[default=no]
The use of the Boost pool allocator only affects std::map
, and the code performs adequately without it. The option should be removed, and the Boost pool allocator should no longer be used.
--with-dense-mat uses dense matrices [default=yes]
While the code works with sparse matrices, in practice the uBLAS
sparse implementation is too slow for general arithmetic operations, while multi-gigabyte memory spaces are now common. The option should be removed, and matrices should be dense, with the exception of the matrices used for the basis element cache.
--with-random[=ARG] type of random number generator to use
(std|gsl) [default=std]
The C++11 standard random number generators essentially supercede the GSL random number generators. The option should be removed, and the standard random number generators should always be used.
Running clang-tidy
with bugprone-*
checks, except for bugprone-reserved-identifier
and `bugprone-easily-swappable-parameters' results in:
leopardi@pensieri:~/sync/src/glucat/git/glucat$ clang-tidy.sh 'bugprone-*,-bugprone-reserved-identifier,-bugprone-easily-swappable-parameters'
245 warnings generated.
./glucat/framed_multi_imp.h:297:9: warning: repeated branch in conditional chain [bugprone-branch-clone]
return false;
^
./glucat/framed_multi_imp.h:297:21: note: end of the original
return false;
^
./glucat/framed_multi_imp.h:299:9: note: clone 1 starts here
return false;
^
./glucat/index_set_imp.h:71:38: warning: either cast from 'int' to 'glucat::set_value_t' (aka 'unsigned long') is ineffective, or there is loss of precision before the conversion [bugprone-misplaced-widening-cast]
if (!prechecked && folded_val >= set_value_t(1 << frm.count()))
^
./glucat/index_set_imp.h:1007:3: warning: operator=() does not handle self-assignment properly [bugprone-unhandled-self-assignment]
operator= (const reference& j) -> reference&
^
Suppressed 232 warnings (232 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Fix these issues.
Some of the Glucat headers are not self-contained. For example, compiling the following code in framed_multi.cpp
:
#include "glucat/framed_multi.h"
int main(int argc, char ** argv)
{ return 0; }
using
g++ -std=c++11 -std=c++11 -DHAVE_CONFIG_H -I. -I.. -I. -I.. -Wall -g -O3 -march=native -finline-limit=8000 --param large-function-insns=8000 --param max-inline-insns-auto=8000 --param max-inline-insns-single=8000 --param inline-unit-growth=200 --param large-function-growth=200 -funroll-loops -fvariable-expansion-in-unroller -DNDEBUG -D_GLUCAT_USE_STD_UNORDERED_MAP -D_GLUCAT_USE_DENSE_MATRICES -D_GLUCAT_CHECK_ISNAN -Wno-unused-local-typedefs -Wno-deprecated-register -fno-check-new -DHAVE_BITS_WORDSIZE_H -D_GLUCAT_HAVE_BOOST_SERIALIZATION_ARRAY_WRAPPER_H -fexceptions -MT framed_multi.o -MD -MP -MF .deps/framed_multi.Tpo -c -o framed_multi.o framed_multi.cpp
results in
In file included from framed_multi.cpp:32:
../glucat/framed_multi.h:118:56: error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive]
118 | operator<< (std::ostream& os, const std::pair< const index_set<LO,HI>, Scalar_T >& term) -> std::ostream&;
| ^~~~~~~~~
../glucat/framed_multi.h:118:83: error: wrong number of template arguments (1, should be 2)
118 | operator<< (std::ostream& os, const std::pair< const index_set<LO,HI>, Scalar_T >& term) -> std::ostream&;
| ^
In file included from /usr/include/c++/11/bits/stl_algobase.h:64,
from /usr/include/c++/11/bits/char_traits.h:39,
from /usr/include/c++/11/string:40,
from ../glucat/errors.h:34,
from ../glucat/framed_multi.h:35,
from framed_multi.cpp:32:
/usr/include/c++/11/bits/stl_pair.h:211:12: note: provided for ‘template<class _T1, class _T2> struct std::pair’
211 | struct pair
| ^~~~
[...]
See (e.g.) https://www.modernescpp.com/index.php/c-core-guidelines-the-remaining-rules-to-source-files
For now, the headers that use Tune_P
will still need to depend on the user or tests defining this type. This will be treated in a separate issue.
The current code is entirely written and documented in English. It needs an internationalization framework and translations if it is ever to be available in other languages.
Some related issues:
./configure
should check for the Python 3 version of Cython, independently the of Linux distribution.pyclical/PyClical_nocython.cpp
, but this file is not in the Git repository. Therefore building from a Git clone depends on Cython being available, and fails otherwise.make dist
can fail if pyclical/PyClical_nocython.cpp
does not already exist, even if Cython is available. Instead, it should create pyclical/PyClical_nocython.cpp
.GluCat uses uBLAS for linear algebra, except for finding eigenvalues, where it uses Boost Bindings. The two different libraries use different matrix formats. Also, uBLAS is quite slow, especially for algorithms such as the addition of compressed matrices. Perhaps Blaze would be better for finding eigenvalues? First step is to add it as an option alongside Boost Bindings.
Even though the build system of GluCat has recently been overhauled, it still uses Autotools. Since (as a separate issue) a port from uBLAS to Armadillo is being considered, this could be an opportunity to port the build system to CMake. This could have other advantages, including an opportunity to refactor the test and example programs. Another possible longer term advantage would be to enable a port to Windows.
See: StackOverflow: "Tutorial for converting autotools to cmake", StackOverflow: "Linking to Armadillo libraries with CMake".
Following on from Issue #40 , remove the configuration options that are now deprecated, remove the associated tests, and remove the associated #define
macro names and #if defined
branches, to declutter the configuration, code, and tests.
GluCat 0.8.3, as currently distributed, does not include the DESIGN
file. Add this file to doc_DATA
in Makefile.am.in
so that it is included in the distribution.
Modernize the header code by using range-based for loops when appropriate.
The test results and documentation need to be updated to reflect current compilers, tools, etc. in preparation for the release of version 0.9.0.
Testing should use as many compilers and versions as is feasible, since the C++ header code now needs C++11.
The code has INSTALL, README and TODO files, as well as Doxygen documentation, programming examples, and Python help and tutorials. One thing that is still missing is a manual written from a user's perspective. The existing documentation, examples and tutorials provide good starting materials for such a manual. My Masters thesis from UNSW in 2002 could also provide introductory and supporting material.
The Denman-Beavers matrix square root algorithm does not work for singular matrices. Try using the cyclic reduction algorithm of Beatrice Meini. Use this as an opportunity to overhaul the sqrt and log functions and related tuning and tests.
Reference: Beatrice Meini, "The Matrix Square Root From a New Functional Perspective: Theoretical Results and Computational Issues", SIAM Journal on Matrix Analysis and Applications 26(2):362-376, 2004.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.