Compressed Continuous Computation Library in Python
Project description
Compressed Continuous Computation (C3)
Computing with functions
The Compressed Continuous Computation (C3) package is intended to make it easy to perform continuous linear and multilinear algebra with multidimensional functions. It works by representing multidimensional functions in a low-rank format. Common tasks include taking "matrix" decompositions of vector- or matrix-valued functions, adding or multiplying functions together, integrating multidimensional functions, and much much more. The following is a sampling of capabilities
- Adaptive approximation of a black-box model (specified as a function pointer)
- Regression of a model from data
- Both linear and nonlinear approximation
- Approximation in polynomial, piecewise polynomial, linear element, and radial basis function spaces
- General adaptive integration schemes
- Differentiation
- Multiplication
- Addition
- Rounding
- Computing Jacobians and Hessians
- UQ
- Expectation and variance
- Sobol sensitivities
In addition to the above capabilities, which are unique to the C3 package, I also have general optimization routines including
- BFGS
- LBFGS
- Gradient descent
- Stochastic Gradient with ADAM
Documentation of most functions is provided by Doxygen here.
Installation / Getting started
The dependencies for this code are
- BLAS
- LAPACK
- SWIG (if building non-C interfaces)
- CMake
Usually, these dependencies can be installed via the package manager of your system (apt or brew or port)
From Source
git clone https://github.com/goroda/Compressed-Continuous-Computation.git c3
cd c3
mkdir build
cd build
cmake ..
make
This will install all shared libraries into c3/build/src. The main shared library is libc3, the rest are all submodules. To install to a particular location use
cmake .. -DCMAKE_INSTALL_PREFIX=/your/choice
make install
Python interface
You can install the python interface using the pip utility through
pip install pathlib
pip install c3py
One can obtain some examples in the pyexamples subdirectory
python pywrappers/pytest.py
An alternative way to install it is to download the git repository and then run
python setup.py build
python setup.py install
One workflow that works well is to install this package in a new virtual environment. For instance using conda one can run the following (from the c3 directory)
conda create -n c3pyenv python=3.7
conda activate c3pyenv
pip install numpy
python setup.py build
python setup.py install
If you have an old version installed and would like to upgrade the following command is effective at removing all old code and reinstalling
pip install --upgrade --force-reinstall c3py
Configuration Options
The following configuration options take boolean (true/false) values
BUILD_STATIC_LIB
Default: `OFF'
Using this option can toggle whether or not static or shared libraries should be built.
Note: This option cannot be set to ON if building the python wrapper
BUILD_SUB_LIBS
Default: `OFF'
Using this option can toggle whether or not to build each sub-library into its own library
BUILD_TESTS
Default: `OFF'
Using this option can toggle whether or not to build unit tests
BUILD_EXAMPLES
Default: `OFF'
Using this option can toggle whether or not to compile exampels
BUILD_PROFILING
Default: `OFF'
Using this option can toggle whether or not to compile the profiling executables
BUILD_BENCHMARKS
Default: `OFF'
Using this option can toggle whether or not to compile the benchmarks tests
BUILD_UTILITIES
Default: `OFF'
Using this option can toggle whether or not to compile the utilities
LIB_VISIBILITY_OFF
Default: `OFF'
Using this option addes the flag -fvisibility=hidden
to compilation. Useful when embedding this library in a C++ library to hide its symbols.
Systems I have tested on
- Mac OS X with clang version 8.0
- Ubuntu with gcc version 5.0
Solutions to some possible problems
Error: Unable to find 'python.swg'
On Mac OS X, if SWIG is installed with macports using
sudo port install swig
then the above error might occur. To remedy this error install the swig-python package
sudo port install swig-python
(On Mac OS X) Error: stdio.h not found
This happens on some updated versions of Mac OS X. To solve this, the following StackOverflow thread seems to work
https://stackoverflow.com/questions/52509602/cant-compile-c-program-on-a-mac-after-upgrade-to-mojave
Numpy errors
Sometimes you may see the following errors
_frozen_importlib:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216, got 192
or
RuntimeError: The current Numpy installation ('/Users/alex/anaconda3/envs/pytorch/lib/python3.6/site-packages/numpy/__init__.py') fails to pass simple sanity checks. This can be caused for example by incorrect BLAS library being linked in, or by mixing package managers (pip, conda, apt, ...). Search closed numpy issues for similar problems.
One way that I have found (https://stackoverflow.com/a/47975375) that seems to solve this is to upgrade numpy by running the following command. I am really not sure why this works ...
sudo pip install numpy --upgrade --ignore-installed
Coding practices
I aim to document (with Doxygen) every function available to the user and provide a unit test. Furthermore, I won't push code to the master branch that has memory leaks. I am constantly looking for more suggestions for improving the robustness of the code if any issues are encountered.
Contributing
Please open a Github issue to ask a question, report a bug, or to request features. To contribute, fork the repository and setup a branch.
Author: Alex A. Gorodetsky
Contact: goroda@umich.edu
Copyright (c) 2014-2016, Massachusetts Institute of Technology
Copyright (c) 2016-2017, Sandia National Laboratories
Copyright (c) 2018-2021, University of Michigan
License: BSD
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file c3py-0.0.7.tar.gz
.
File metadata
- Download URL: c3py-0.0.7.tar.gz
- Upload date:
- Size: 18.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.8.2 requests/2.27.1 setuptools/57.0.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d65026dc3ebbf1fc04274ca43a4d5dfc6f35ad6672e43791f207f7403cbaf1f1 |
|
MD5 | 4f1798bf473b3a9cbcee4c4ad43b1239 |
|
BLAKE2b-256 | 7b46e51f4a4bca13dcb5eccc34c7d35691560052c1733535ca4b772f4c07a495 |
File details
Details for the file c3py-0.0.7-cp39-cp39-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: c3py-0.0.7-cp39-cp39-macosx_10_14_x86_64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.9, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.8.2 requests/2.27.1 setuptools/57.0.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b327ebffd42451ba02309b6741ed031733e711faea9b029ca52035466c93d8e |
|
MD5 | 4d19e4ef5e711308a28d9f332231a603 |
|
BLAKE2b-256 | 79dffe6dc19b833c0d9eb05f5eab81b1c866c34908d8d7480da6d12693be8be3 |