« first day (636 days earlier)      last day (3865 days later) » 

12:34 AM
@halirutan I'm here. You're right that this is not portable. It seemed better for my use case than setting DYLD_LIBRARY_PATH, but it definitely has the portability problem.
 
1:07 AM
@Szabolcs here too
@Szabolcs OK, I was giving you bad advice because IMO we have to differentiate between two scenarios:
1. You are currently developing a package containing LibraryLink functions.
I assumed you do this.
When you are actively working on such a package, it is most likely not installed in your $UserAddonsDirectory but instead in your development path.
To test and debug your functions it is best when you set you DYLD_LD.. path because then you can simply load and test your functions inside Mathematica. No matter where your dev-path is.
@Szabolcs The 2nd scenario is when you have finished your package dev and it is ready to be installed. Here, there is a much easier way to solve the dependency problem.
The requirement is that your package structure looks like the following example:
IPCU
├── Documentation
│   └── English
│       └── ReferencePages
│           └── Symbols
├── Java
├── Kernel
└── LibraryResources
    ├── Linux-x86-64
    ├── MacOSX-x86-64
    ├── Windows
    └── Windows-x86-64
Important is the LibraryResources directory and its division into valid $SystemID folders
Now you put all your compiled and the dependency libraries in the appropriate folder and when you load the package, the following happens:
<< IPCU`
$LibraryPath
The $LibraryPath (the internal Mathematica variable specifying where it searches for libs) contains
/home/patrick/.Mathematica/Applications/IPCU/LibraryResources/Linux-x86-64
automatically.
@Szabolcs Now Mathematica will be able to find all your libraries you have put there.
In[6]:= FindLibrary["libtbb"]

Out[6]= "/home/patrick/.Mathematica/Applications/IPCU/LibraryResources/Linux-x86-64/libtbb.so"
and Mathematica provides a command to load dependent libraries upfront:
LibraryLoad["libtbb"]
If you check the doc for LibraryLoad you see:
> LibraryLoad is used to load dependent dynamic libraries needed for a Wolfram Library to operate.
> Libraries loaded using LibraryLoad do not need to follow the Wolfram Library Link specification.
> The order of multiple LibraryLoad calls is important and must follow the mutual dependency of the libraries.
> LibraryLoad uses FindLibrary to locate libraries searching on $LibraryPath.
Therefore, the official way to make your LibraryLink package work through the systems is to 1. provide you lib and all deps in the appropriate folder 2. load all dependencies upfront using LibraryLoad and 3. Load your functions using LibraryFunctionLoad.
Unfortunately, this way does not work reliably through all systems, meaning I could only use it in Windoze.
@Szabolcs I'm in investigating this issue right now, but if you like I can add that answer to your question.
 
1:35 AM
@halirutan That is sheer dedication to formatting...
 
@rm-rf This is called tree
:-)
Works on OSX too with macport or friends
 
@halirutan Ahhh... I forgot about tree! OK, praise withdrawn :P
 
@Szabolcs Thanks so much for bringing this issue up. It indeed works even on Linux, testing now for OSX. I only made a simple error. Hell yeeeahh now my package distribution will be a looot easier ;-)
 
2:01 AM
@halirutan So LibraryLoad can do everything then!
 
@Szabolcs Yes. It finally worked on OSX, Linux and Windows for me!
I'm writing up an answer right now
 
@halirutan Do you want to post an answer to my question from today?
@halirutan OK, great!
 
 
4 hours later…
5:51 AM
I have a list x and a list of lists ys, and I want to find all ways to cut x into three parts such that the middle one is in ys. What 's a fact way of doing that?
 
Have you any working solutions?
 
looking at all segments of x of lengths equal to the lengths of ys...
somewhat catastrophic
 
My initial thought (and I'm far from a resident guru, fyi) is to find where the y's are in x using Position calls.
 
How do you use Position for that?
 
though I suppose that has an ordering issue
Is this cut just supposed to cut out the y part, and the stuff to the left is another part, and stuff to the right a third part? Or can you arbitrarily partition up the remainder (in which case there will usually be an absurd number of possibilities).
 
5:56 AM
a cut is a triple (left, middle, right) such that the concatenation of the three lists is the initial x
there is no StringPosition for lists, no?
 
You might be able to use it by replacing the List head
I've never worked with Strings, so I don't know. But does something like String@@{1,2,3} convert it from a list to some sort of string?
 
That might not be the most efficient method, but maybe an improvement over "catastrophic" at least.
 
I'm fairly sure the best idea is beyond my experience. Possibly some sort of pattern matching thing can be done for it?
 
6:03 AM
«{1, 2, 3, 4} /. {a___, PatternSequence[2, 3], b___} :> {a, b}» does work
 
Ah, that should do it, then.
 
cuts[x_, ys_] := ReplaceList[x, ({a___, PatternSequence @@ #, b___} :> {{a}, #, {b}}) & /@ ys]
cute :-)
 
Glad I could barely manage to help, then.
 
thanks, indeed :-)
 
:11683751
ReplaceList[x, {a___, PatternSequence[##], c___} :> {{a}, {##}, {c}}] & @@@ ys
Ups.. too late.
 
6:09 AM
You use many ReplaceLists while I used one, I wonder which is best
 
I assume that depends on the what the technical difference between @@@ and /@ is. An answer which I definitely do not know.
 
@MarianoSuárez-Alvarez I guess with big data both choices are not the best.
 
sure :-)
my args are smallish, so that'snot big issue
 
@MarianoSuárez-Alvarez On bigger lists it's 7.791364 s for my solution and 7.753065 for yours.
You are faster and have 0.04s for a coffee
 
haha
now compare it to using the KMP algorithm :-)
 
6:16 AM
I wish I was doing something that was done in about 8 seconds.
 
you get to drink longer coffees
 
I can't drink coffee.
 
whiskey, then
if life gives you lemon, you drink whiskey
 
I don't drink alcohol. Nor could I afford it even if I did.
I'd eat the lemon, though.
'Cause as I always say, "When life gives you lemons, yay, free food!"
 
6:37 AM
The world would be a very different place if more people chose Mathematica over alcohol. Keep practicing though. All of the good programmers I know eat whatever they want.
 
@MichaelHale true, but can´t I haz both?
 
Definitely. Most of the good programmers I know also drink as much as they want.
 
Aaand lemon (and limes) go nicely with several alcoholic beverages.
 
Indeed.
 
Anyway just lemons: good against scurvy, but ultimately bad for your teeth, as well (I will abstain from posting images).
 
 
4 hours later…
10:39 AM
Hi all, how can i convert a list containing one element of concatenating expression into a list of expressions?
Like
a={A1&&B1&&C1&&D1}
obtaining
a={A1,B1,C1,D1}

??
thanks a lot!
 
11:15 AM
@Yyrkoon Flatten[{A1 && B1 && C1 && D1} /. And -> List]
or Flatten[List @@@ a]
 
or a /. And -> Sequence
 
@PinguinDirk ui, even better, that!
If that were a question, it would feature about 17 answers by now :-)
 
@YvesKlett: yep! It takes something these days to be the first to answer on ListManipulation questions
(which is good)
(unless it's a dupe...)
 
Sequence @@@ a
(mad laughter)
 
11:36 AM
@YvesKlett, ok you win :)
 
@PinguinDirk let´s call it synergy (well, or a really lange Leitung) ;-)
 
I like to call it Monday...
hm. Tuesday actually. :)
 
:-)
anyway, pretty nifty for start o´ the week.
 
12:06 PM
Thank you all!!
 
12:45 PM
Hi, is this a sane way to do memoization for things related to a symbol to make sure the values get cleared when the symbol gets removed?

f[s_Symbol]:=( s /: f[s] = RandomReal[])
 
Good morning @Yyrkoon, @YvesKlett, @PinguinDirk! Happy Flatten[a, 1, And]! :P
 
@MichaelE2: I like that! and thanks for bringing it up again :)
 
@ssch It seems reasonable, it seems to work the way you want it to. I don't feel like I'm well-informed on these sorts of issues though. What do you expect from f[x]; x = 3; f[x]?
 
@MichaelE2 I expect failure from that :)
 
1:00 PM
@ssch Then it works! ;)
 
@MichaelE2 verry nice and highly educational!
 
 
4 hours later…
5:05 PM
All, check out this post by Vitaliy on Wolfram Community.
2
 
 
1 hour later…
6:12 PM
@rcollyer hey are you around?
 
6:54 PM
@VitaliyKaurov now I am.
 
@rcollyer i already sent internal email - i think u have seen
 
@VitaliyKaurov no, I haven't. I'm on lunch and just got to a computer.
 
@rcollyer Save As HTML option - I wonder if anyone knows the switch so code is saved not as images but as html
 
@VitaliyKaurov interesting question. I don't know that answer, unfortunately.
 
@rcollyer np, i'll figure it out
 
6:58 PM
@VitaliyKaurov good luck. :)
 
7:44 PM
Hi all! Is there anyone using the Intel MKL here?
 
 
2 hours later…
9:40 PM
@halirutan Do you know what a LibraryLink function is supposed to return on abort (i.e. finding AbortQ() to be true)? Just a LIBRARY_SOMETHING_ERROR? or LIBRARY_NO_ERROR?
 
 
1 hour later…
10:49 PM
@Szabolcs Yes, I believe I read about it.
@Szabolcs I think I mix things up with MathLink.
From the top of my head I would say that on Abort it is not a library function error, therefore, you should return LIBRARY_NO_ERROR.
What you have to ensure is that no further calculations are done. I remember a MathLink doc/thread/post/QA were this was discussed and the conclusion was to return Abort[] instead of $Abort to ensure everything that follows is aborted too.
@Szabolcs Ahh, I found it. It was mentioned in a pdf from Todd Gayley indeed for MathLink. Please read section 1.10.3 in this pdf.
I don't know whether this works at all, but what I would try to do is to return Abort[] from the library function (Callback Evaluations in Mathematica) and then return NO_ERROR
 
11:28 PM
@Szabolcs OK, a small example showed that it does not seem to be important what you return. You can simply do
if (libData->AbortQ()) {
  return LIBRARY_NO_ERROR;
}
and it works.
 

« first day (636 days earlier)      last day (3865 days later) »