Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monster PR - vectors, matrices, number theory bindings #12

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c3a13f5
started binding CVec
bollu Nov 21, 2016
41861c1
started writing code to use Symengine exceptions, simplified code to …
bollu Nov 22, 2016
327d249
add a list of things you learnt along the way
bollu Nov 22, 2016
af90964
added error handling code so vectors dont crash on out of bounds
bollu Nov 24, 2016
89da046
implement vector with foreign pointer, started binding dense matrix
bollu Nov 25, 2016
f7ae2e6
started binding dense matrices
bollu Nov 25, 2016
057e308
added test for dense matrices
bollu Nov 25, 2016
de1032b
added checks to bounds in basicvec, as isuruf said that such checks s…
bollu Nov 25, 2016
c991b35
touched README so travis build is triggered
bollu Nov 25, 2016
fd4a5d2
made versions of cabal to be newer
bollu Nov 25, 2016
6a42612
changed a bunch of definitions to make the code simpler
bollu Nov 30, 2016
bb1d570
added a typeclass called Wrapped that represents ForeignPtr's wrapped…
bollu Nov 30, 2016
1777564
implemented getter for matrix
bollu Nov 30, 2016
8d22266
added getter for CDenseMatrix
bollu Nov 30, 2016
7d6ee7d
added dimensions access to dense matrix
bollu Nov 30, 2016
cf027a5
fixed get_size
bollu Nov 30, 2016
4440d9b
changed travis file to use the correct cabal, GHC version. BUMP
bollu Nov 30, 2016
e268442
added more dense matrix code
bollu Dec 8, 2016
dfdc5df
bound dense matrix solves, need to write test cases
bollu Dec 8, 2016
f7a707f
rewrote modules to be split into separate code
bollu Dec 9, 2016
9151a80
no longer allow a densematrix_new and vecbasic_new. Should be IO
bollu Dec 10, 2016
d5538bb
dependant typing is matrix. DenseMatrix size is now dependant typed
bollu Dec 11, 2016
35c7c74
made eye into typed function
bollu Dec 12, 2016
5bd0861
changed densematrix_get to be type level
bollu Dec 12, 2016
d9c5e4b
fully typed densematrix API
bollu Dec 12, 2016
82ec441
made code referentially transparent
bollu Dec 13, 2016
a3fa4ef
add comment about debacle with densematrix_set
bollu Dec 13, 2016
a96e5be
continue building number theory
bollu Dec 13, 2016
30411db
implemented number theory bindings
bollu Dec 14, 2016
16ebc01
changed the way basicsym, densematrix is constructed to now abuse mkF…
bollu Dec 14, 2016
a26e46e
edited VecBasic as well to prevent weird memory races. Hope this is c…
bollu Dec 14, 2016
afe7aed
edited basic_unaryop to do the construction thing
bollu Dec 14, 2016
5add770
identity of + is crashing
bollu Dec 14, 2016
9f549b4
DOES NOT COMPILE: turns out memory is _not_ the problem. changed all …
bollu Dec 15, 2016
ad21095
minimal test case: create and do nothing. crashes
bollu Dec 15, 2016
50f002d
found the error. divide by 0. I was assuming Q, (*) is a group, and n…
bollu Dec 15, 2016
7e2e5fc
crash fixed: removed test case that tried to invert 0. Need to actual…
bollu Dec 15, 2016
7a681fa
changed basicsym_binaryop to deal with exceptions. TODO: edit other c…
bollu Dec 15, 2016
a7ee3fb
added algebra-based test cases. Implemented det, inv, etc.
bollu Dec 15, 2016
27722bd
expose transpose
bollu Dec 15, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 8 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,49 +46,30 @@ matrix:
#- env: BUILD=cabal GHCVER=7.2.2 CABALVER=1.16 HAPPYVER=1.19.5 ALEXVER=3.1.7
# compiler: ": #GHC 7.2.2"
# addons: {apt: {packages: [cabal-install-1.16,ghc-7.2.2,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc, ubuntu-toolchain-r-test]}}
- env: BUILD=cabal GHCVER=7.4.2 CABALVER=1.16 HAPPYVER=1.19.5 ALEXVER=3.1.7
compiler: ": #GHC 7.4.2"
addons: {apt: {packages: [libgmp-dev,
libmpfr-dev,
libmpc-dev,
binutils-dev,
g++-4.7,
gcc, cabal-install-1.16,ghc-7.4.2,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc, ubuntu-toolchain-r-test]}}
- env: BUILD=cabal GHCVER=7.6.3 CABALVER=1.16 HAPPYVER=1.19.5 ALEXVER=3.1.7
compiler: ": #GHC 7.6.3"
addons: {apt: {packages: [libgmp-dev,
libmpfr-dev,
libmpc-dev,
binutils-dev,
g++-4.7,
gcc, cabal-install-1.16,ghc-7.6.3,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc, ubuntu-toolchain-r-test]}}
- env: BUILD=cabal GHCVER=7.8.4 CABALVER=1.18 HAPPYVER=1.19.5 ALEXVER=3.1.7
- env: BUILD=cabal CABALVER=1.24 GHCVER=7.8.4 STACK_YAML=stack-7.8.yaml
compiler: ": #GHC 7.8.4"
addons: {apt: {packages: [libgmp-dev,
libmpfr-dev,
libmpc-dev,
binutils-dev,
g++-4.7,
gcc, cabal-install-1.18,ghc-7.8.4,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc, ubuntu-toolchain-r-test]}}
- env: BUILD=cabal GHCVER=7.10.3 CABALVER=1.22 HAPPYVER=1.19.5 ALEXVER=3.1.7
gcc, cabal-install-1.24,ghc-7.8.4,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc, ubuntu-toolchain-r-test]}}
- env: BUILD=cabal CABALVER=1.22 GHCVER=7.10.3
compiler: ": #GHC 7.10.3"
addons: {apt: {packages: [libgmp-dev,
libmpfr-dev,
libmpc-dev,
binutils-dev,
g++-4.7,
gcc, cabal-install-1.22,ghc-7.10.3,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc, ubuntu-toolchain-r-test]}}

# Build with the newest GHC and cabal-install. This is an accepted failure,
# see below.
- env: BUILD=cabal GHCVER=head CABALVER=head HAPPYVER=1.19.5 ALEXVER=3.1.7
compiler: ": #GHC HEAD"
- env: BUILD=cabal CABALVER=1.24 GHCVER=8.0.1
compiler: ": #GHC 8.0.1"
addons: {apt: {packages: [libgmp-dev,
libmpfr-dev,
libmpc-dev,
binutils-dev,
g++-4.7,
gcc, cabal-install-head,ghc-head,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc, ubuntu-toolchain-r-test]}}
gcc, cabal-install-1.24,ghc-8.0.1,happy-1.19.5,alex-3.1.7], sources: [hvr-ghc, ubuntu-toolchain-r-test]}}

# The Stack builds. We can pass in arbitrary Stack arguments via the ARGS
# variable, such as using --stack-yaml to point to a different file.
Expand Down Expand Up @@ -210,6 +191,8 @@ install:

# Download and unpack the stack executable
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.local/bin:/opt/alex/$ALEXVER/bin:/opt/happy/$HAPPYVER/bin:$HOME/.cabal/bin:$PATH
# add cabal install path
- export PATH=PATH="$HOME/.cabal/bin:$PATH"
- mkdir -p ~/.local/bin
- |
if [ `uname` = "Darwin" ]
Expand Down
60 changes: 55 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ as well as the libraries

Since these are *hard* dependencies for SymEngine-hs to build.

Compile `SymEngine` with the `CMake` flags

```bash
cmake -DWITH_SYMENGINE_THREAD_SAFE=yes -DBUILD_SHARED_LIBS:BOOL=ON
```

# Getting started

To quickly build and check everything is working, run

```
stack build && stack test
stack build && stack test --test-arguments "--quickcheck-tests 2000" --verbose
```

All of the test cases should pass with SymEngine
Expand Down Expand Up @@ -68,14 +74,58 @@ GHCi session with Symengine loaded
-1
```

# Things to Do
# Development

`[TODO: fill this up]`
clone `Symengine`, build it with the setting

# Contributing
```
cmake -DWITH_SYMENGINE_THREAD_SAFE=yes -DBUILD_SHARED_LIBS:BOOL=ON
```

this makes sure that dynamically linked libraries are being built, so we can
link to them.


to test changes, use
```
stack test --force-dirty --test-arguments "--quickcheck-tests 2000" --verbose
```

* change `--quickcheck-tests" to some number (preferably > 100), since it generates those many instances to
test on

* the `--force-dirty` ensures that the library and the test builds are both
rebuilt.

`[TODO: fill this up]`

# License

All code is released under the [MIT License](https://github.com/symengine/symengine.hs/blob/master/LICENSE).


# Things Learnt

* you can use `toEnum` to convert from `Int` to the `C<Int | Long | ..>` variants
of C types

* API design - how to best handle exceptions?

# Bugs

* if I create a lazy list of BasicSym, then what happens? it gets forced to evaluate
when I pass it through something like `densematrix_diag`


* `densematrix_new_vec 2 3 []` crashes. We need to check for this in our code


* What exactly does 'unsafePerformIO' do? why does `unsafePerformIO` on `basicsym_new`
yield weird as hell errors?

* take proper care of ref. transparency. eg: `densematrix_set`

* Maybe allow GHC to tell about "typo errors" when looking for modules

* `merijn You'll want newPinnedByteArray# :: Int# -> State# s -> (#State# s, MutableByteArray# s#)`

* is the API Thread-safe?
Loading