These are chat archives for symengine/symengine

14th
Dec 2016
Siddharth
@bollu
Dec 14 2016 08:33

why is the type of binomial

CWRAPPER_OUTPUT_TYPE ntheory_binomial(basic s, const basic a, unsigned long b)

why not const basic b as well? having the n and the r be two different types in nCr is weird IMO.

I would like some rationale :) since I'm binding it to haskell and writing docs
Isuru Fernando
@isuruf
Dec 14 2016 08:36
@bollu, I think that was because of the mpz interface used
which had the same kind of signature
Siddharth
@bollu
Dec 14 2016 08:37
I see
but, well, what is the "spiritually correct" type?
both as unsigned long, right?
Isuru Fernando
@isuruf
Dec 14 2016 08:37
nope, both as basic
Siddharth
@bollu
Dec 14 2016 08:37
oh
how come?
Isuru Fernando
@isuruf
Dec 14 2016 08:38
because unsigned long can only keep integers < 2**64
Siddharth
@bollu
Dec 14 2016 08:38
what if they try to feed a Complex or something into nCr?
ah
that way
okay
I wish Basic was more strongly typed
Isuru Fernando
@isuruf
Dec 14 2016 08:38
you should check the status
Siddharth
@bollu
Dec 14 2016 08:38
yes, I know :) But it would be cool if things like this were type errors
for example
speaking of, I managed to get the haskell type system to encode a lot of matrix info
densematrix_mul_matrix :: forall r k c. (KnownNat r, KnownNat k, KnownNat c) => 
  DenseMatrix r k -> DenseMatrix k c -> DenseMatrix r c
so your matrix dimensions are part of the type!
so you can't ever send "wrong dimension matrices" into multiplication
:)
Isuru Fernando
@isuruf
Dec 14 2016 08:39
is that dynamic?
Siddharth
@bollu
Dec 14 2016 08:40
in the sense? the types are matched at compile time
Isuru Fernando
@isuruf
Dec 14 2016 08:40
So, you can't make a type of sizes known at runtime?
Siddharth
@bollu
Dec 14 2016 08:40
it can be dynamic, but then everything has to type check (as in, if you dynamically use some size of matrix here, it needs to "agree" with the size elsewhere
I haven't experimented much with that, however
I plan on exposing both
the "static typed" system (for most cases)
Isuru Fernando
@isuruf
Dec 14 2016 08:40
Cool
Siddharth
@bollu
Dec 14 2016 08:40
yeah
Isuru Fernando
@isuruf
Dec 14 2016 08:41
Btw, can you send in small PRs to the repo, so that I can review?
Siddharth
@bollu
Dec 14 2016 08:41
sure
I'm hoping to encode a lot of constraints this way
right now, I'm trying to get it to "somewhat okay"
so I can send you a PR
I'll send you one in the next couple days (~3-4)
cool?
Isuru Fernando
@isuruf
Dec 14 2016 08:42
that's fine. the haskell wrappers are in a very basic state, so anything is okay
Siddharth
@bollu
Dec 14 2016 08:42
OK
Isuru Fernando
@isuruf
Dec 14 2016 08:42
thanks
Siddharth
@bollu
Dec 14 2016 08:42
np!
thanks for letting me write the wrappers. It's been a super fun experience
Isuru Fernando
@isuruf
Dec 14 2016 08:43
I just wanted to make sure the code is reviewed from time to time, so that we don't have to review a big PR
Siddharth
@bollu
Dec 14 2016 08:43
ah, yes, I understand
Isuru Fernando
@isuruf
Dec 14 2016 08:45
Haha. Didn't know C++, Julia or Python before symengine. I was coding in Java back then. It's fun to learn a new language while doing something useful
Siddharth
@bollu
Dec 14 2016 08:45
yes :) I'm learning a lot about type-level power in haskell
Siddharth
@bollu
Dec 14 2016 09:27
@isuruf - can I change the C API to have both parameters as basic in that case?
or does that not make sense either?
Isuru Fernando
@isuruf
Dec 14 2016 09:36
Okay, but the function has to be deprecated though.
Siddharth
@bollu
Dec 14 2016 09:37
which version?
Isuru Fernando
@isuruf
Dec 14 2016 09:37
unsigned long version has to be deprecated
Siddharth
@bollu
Dec 14 2016 09:37
ah, okay
Siddharth
@bollu
Dec 14 2016 17:25
I need to add functions that take a chunk of raw memory and initialise it (with placement new). @isuruf is that OK?
@isuruf - I need this because GHC wants control of memory
because it operates lazily, so there are.. weird memory interactions I don't fully understand
but supposedly allowing GHC to manage memory fixes these
Siddharth
@bollu
Dec 14 2016 19:40
also, is the SymEngine API thread safe?