# Tag Info

9

This is my try in creating a minimal example with only one variable. There are a couple problems to solve: Minuit2 is in C++, so we need a way to integrate it with mathematica through mathlink. This is a bit cumbersome, but in principle straightforward. This first example uses a mathematica function with minimum user input, that is, it does not uses a user-...

5

LibraryLink's complex type, mcomplex, is defined as two contiguous double values. In C++, std::complex<double> has exactly the same layout. This is guaranteed since C++11, but should hold in most other cases too in practice. This means that if you get a complex array from Mathematica, mcomplex *arr = MTensor_getComplexData(t); then you can ...

5

This can be done without using any Mathematica features. You can keep the matrix as a global variable on the C++ side. You will have a function for initializing it, a function for destroying it, and a function for the distance calculation. Then just call the initializer and cleanup function manually from Mathematica when you need to. Note: Storing a ...

3

You might be able to pass the GMP internal array of limbs directly as a list, and then call FromDigits with base = 2^(limb size). This won't require any work on behalf of GMP, though I don't know anything about Mathematica's internals to say how efficient it would be on their end. UPDATE: For the reverse, you could call IntegerDigits.

3

First approach is to create C wrappers for the C++ code. The very simple example I work below defines a class "bola" which represents a sphere with a radius. The member function gives the surface. So, the forward definition (C++ style) of the class functions is in "bola.h" and the definitions of the functions are in "bola.cpp". I give the code for these two ...

2

Based on Todd Gayley's response here and trying it out, it can be done using MLTransferExpression(NULL, link) This will remove one complete (sub)expression form the link. The code for the example from the question would be int argc = 2; if (! MLTestHeadWithArgCount(link, "f", &argc)) { // fail } MLTransferExpression(NULL, link); int i; ...

2

You are inconsistent with the number of entries in your arrays. You seem to want 5. mymatrix = Table[RandomInteger[1], {5}, {5}]; hub = {1, 1, 1, 1, 1}; auth = {0, 0, 0, 0, 0}; Table[If[mymatrix[[i, j]] == 1, auth[[i]] = auth[[i]] + hub[[j]]], {i, 5}, {j, 5}]; auth or mymatrix = Table[RandomInteger[1], {5}, {5}]; hub = {1, 1, 1, 1, 1}; auth = {0, 0, ...

2

I'm not sure if this answers your question but it's a bit long for a comment. One efficient approach is to convert the parts before and after radix into a base that is a power of 2 e.g. 2^16, and then process that list so each bigit ("bignum digit") is encoded as a hex string. Here is an example. Map[StringDelete[ToString[BaseForm[#, 16]], "\n" ~~ __] &...

2

Use SetDelayed (:=) a = x^2; b := a^2 ?b b:=a^2 As you can see, b is still a^2. http://reference.wolfram.com/language/ref/SetDelayed.html

1

Thanks to Szabolcs for pointing out the right way. So I rewrite the real Inverse version into complex version, and pasted here for reference. libnewsource="#include<complex> #include<Eigen/Dense> #include<Eigen/LU> #include \"WolframLibrary.h\" DLLEXPORT mint WolframLibrary_getVersion(){return WolframLibraryVersion;} DLLEXPORT int ...

Only top voted, non community-wiki answers of a minimum length are eligible