I have an F# project that uses MathNet.Numerics for Linear Algebra routines.
I have placed the following code in an F# module:
module LinearAlgebra
open MathNet.Numerics
open MathNet.Numerics.LinearAlgebra.Double
open MathNet.Numerics.LinearAlgebra.Generic
Control.LinearAlgebraProvider <- new Algorithms.LinearAlgebra.Mkl.MklLinearAlgebraProvider()
But the times I am seeing for matrix multiplication remain the same whether I have this line of code enabled or commented out.
I have installed the Mkl provider NuGet package as described here:
http://christoph.ruegg.name/blog/mathnet-numerics-with-native-linear-algebra.html
and have ensured that these two dlls are copied to the bin directory:
libiomp5md.dll
MathNet.Numerics.MKL.dll
Any ideas about how I can detect if the native provider is actually being used?
The docs are a bit more up to date than the mentioned blog post, but it seems all the required steps have been done.
How large are your matrices?
Are all the involved matrices dense?
Is this module the module where your linear algebra code is in? If not, have you made sure that this module is actually executed - before the linear algebra code?
You can verify the native provider is enabled by checking Control.LinearAlgebraProvider right before the linear algebra code is executed. In v3, calling ToString on it will provide some additional info like platform and revision as well.
Related
I"m looking at converting a dart package (https://pub.dev/packages/sounds) to a federated model using pigeon.
The documentation around combing these two pieces is a little sparse.
Looking at the video_player sample (https://github.com/flutter/plugins/tree/master/packages/video_player/video_player_platform_interface) seems to suggest a federated model as the web platform is separate.
However both the android and ios packages are part of the main package.
Is this just an historical artefact or do the ios and android packages still need to be part of the main plugin?
If they can be separated out what is the correct package(s) structure?
Are then any open source plugins that use pigeon in a fully federated model that could be used as samples?
Having the iOS and Android projects inside of the main package is the standard as of now. I looks like there's discussion around generating federated plugins when running flutter create.
There is an article on the url_launcher federated plugin model refactor which is helpful for figuring out the FS structure:
https://medium.com/flutter/how-to-write-a-flutter-web-plugin-part-2-afdddb69ece6
https://github.com/flutter/plugins/tree/master/packages/url_launcher
As far as Pigeon is concerned, because Pigeon is in pre-release and the federated plugin design is fairly new, I doubt there are any fully federated open source packages using Pigeon. However it seems like your message spec would be owned by the my_plugin_platform_interface package and the generated code would be copied over to your platform specific package e.g. my_plugin_ios, my_plugin_android, my_plugin_macos, etc.
Hope that's of some use.
Why is video_player's android and iOS code not federated?
Is this just an historical artefact or do the ios and android packages still need to be part of the main plugin?
It appears to either be:
a convenience: flutter create will create a package easily with android/ios boilerplate
historical artefact: They might have created the package before federated plugins were released. (This is why people have requested the flutter create plugin template to generated a federated plugin automatically).
Correct package structure
If they can be separated out what is the correct package(s) structure?
They can be separated out.
For pigeon specifically, you can put the Dart generated code (from Pigeon) in your Platform specific interface, and your Native platform generated code (from Pigeon) in your platform specific package.
In your platform specific package, you should declare it to be a federated plugin (see docs and url_launcher), where url_launcher is the app facing package in that example:
flutter:
plugin:
implements: url_launcher
platforms:
macos:
pluginClass: UrlLauncherPlugin
fileName: url_launcher_macos.dart
Example package
If you take a look at url_launcher, all platforms have federated plugin packages.
Why federate
The advantage of creating a separate platform specific package is that a user can override the default implementation. For video_player, a user cannot override Android or iOS implementation because it is in the app-facing package.
More reading
After writing the above, I found this GitHub issue which goes over a lot of our concerns: https://github.com/woodemi/quick_flutter.brick/issues/22
My world is computational statistics and I thought I would try out forio-epicenter for creating applications. Clearly I am able to call Python functions from forio-epicenter. However, am I able to call a Python function that calls a C function?
That is possible, though it may be mildly tricky. You'll have to compile the C code to a shared library, and it'll have to be compiled for 64-bit Linux (Ubuntu, though that shouldn't really matter too much). That shared library will have to be uploaded to your model directory in Forio Epicenter.
For wrapping the C library, there are three possibilities, more or less. SWIG doesn't require any support from Forio to be usable, you'll build the Python wrapper off-line and upload it to your model directory. Cython or CFFI can both be supported, though as of this writing they aren't. If you're interested, let us know, and support can quickly be added for either of those solutions (and it is planned to do both eventually anyway).
Swig
Cython
Disclaimer: I currently work at Forio
I want to open libraries, because currently I want to see the algorithms used for drawing, modify them and implement them in my program. For example: I have tried to create an algorithm on my own for lines. But I failed. And even if I had succeeded, I fear that it might not give the same result as the algorithm in the libraries. And I don't want this to happen. That's why I want to copy the algorithms used for the methods in libraries. And I really hope that this will help me create the application I'm currently working on and with other applications in the future.
I tried to open the libraries with a code editor. But I had troubles finding the libraries- I don't really know where are they placed nor in what files are their codes stored.
How to open a Java library? Or is there a place in the Internet where the code is uploaded?
It sounds like what you want is to get inside the standard Java libraries (so you can see the code for methods like Graphics.drawLine()).
You can download the source files from the same place you got the JDK, if you are on Windows or Linux. For the Mac, see this question. You can even set up Eclipse so that you can debug into that source as if it were your own code.
However, you will probably not find line-drawing code in Java in these libraries - the Graphics implementation will almost certainly use native methods, and may just call existing methods in the OS.
If you are specifically looking for line drawing algorithms, another option would be to look at the Wikipedia page for the Bresenham (aliased) or Wu (antialiased) algorithm.
Edit:
The part of a Graphics2D call that actually puts pixels on the screen is probably inside a system call and therefore the source would not be available.
A java vector graphics library like Batik might have source for some of these algorithms, but probably relies on the Graphics2D calls for most of them. So, you might look for a comprehensive vector graphics library written in a language other than Java, where those graphics calls do not already exist by default.
Alternately, checking the table of contents for a computer graphics book might point you at a variety of algorithms that you could look up on Wikipedia.
For any given library:
Make sure to obey all licenses when using another's code
If you are referring to the Java SDK source code, you can find it here: http://grepcode.com/
If the project is open source, you can usually just get the source from the project website. No problem, though make sure to obey their license.
If the project is NOT open source, well, then you're in a pickle licensing wise, so I do NOT endorse this, however, you would need to use a Java Decompiler such as JD-Gui
As far as what drawing algorithms to use, there are so many different ones (obviously, people have been trying to draw quickly for many many years), your best bet is to figure out exactly what you need to do and then search for that specific need separately. There isn't really a good repository of ALL of them, except maybe wikipedia.
If you are using the libraries they are on your classpath. Check out how to figure out your classpath in whichever IDE you are using and you can find the JARs you depend on. If they are packaged with sources all you need to do it unjar them and look at the sources.
If you don't have access to the sources you can get the code using a Java Decompiler.
If you are trying to look at a standard Java library, see the other answers about getting the source to the JDK.
If you are interested in an open source library (such as something maintained by the Apache project), look on the site of the project for a 'source jar' which you can open with a standard zip utility.
If the library you want is not open source or you cannot find the source for it, you can try to decompile it. If you are using Eclipse, try this decompiler.
I'm interested in playing around with the MaxSAT/MaxSMT c example (specifically, maxsat.c) provided on the z3 (Microsoft Research) website. Using Visual Studio 2010, I eventually got the example to compile (using a fresh install of z3 4.0). However, I can't get any of my (SMT 2.0) models to run using them. Further, I cannot get the example posted in this question to work either.
In the first case, my compiled program crashes when it tries to call Z3_get_smtlib_num_formulas in get_hard_constraints of the file. I don't know why, instead, I get the standard windows 7 "this program has stopped working" popup.
In the second case, it reports unsupported ;benchmark.
In order to help me to get this work, I was wondering if
(a) Has anyone had similar issues when compiling this code, and if so, how did you resolve them?
or
(b) How can I debug either compilation of the file (assuming it is correct)? Namely, can someone enumerate the correct libraries (and library versions - e.g., z3 4.0?) to include in the compiler options to get this example working?
In either case, information on the error reported in the second case would also be appreciated: what does it mean exactly? The keyword was not valid? That the SMT input is the wrong version? Or something else?
Thanks.
The MaxSAT example has not been updated to SMTLIB 2.0 yet. It uses the function Z3_parse_smtlib_file to parse the input, which means that it supports only SMTLIB 1.0 at the moment.
This example is distributed alongside Z3, i.e., you should have received a copy in Z3-4.0/examples/maxsat/, which also contains compilation and execution scripts.
Compilation should be straight-forward by running build.cmd in a Visual Studio Command Prompt, or build.sh on Linux.
I am working on a project where I have to detect the features of an object (in a Video Frame) and match it with other objects (inside some other frame) to recognize the same object for tracking. I have googled many Feature detector algorithms. I also did some comparisons between them (SIFT,SURF & ASIFT).
ASIFT is computationally a bit expensive but the results are more accurate when compared to SIFT & SURF.
I have googled a lot about ASIFT but did not get any success regarding my project.
Can someone please help me with using ASIFT in my project?
ASIFT reference:
http://www.ipol.im/pub/algo/my_affine_sift/
Which files should I include in my project? I'm working on OPENCV 2.1 , IDE VS 2010.
Its my first post on this platform. Hope some one will help me.
The important functions are in the files compute_asift_keypoints.{c,h} and compute_asift_matches.{c,h}. They will inform you about which functions are mandatory. From there you have the choice:
Quick-and-dirty way:
you need to include and compile everything, except the executable part (file demo_*.cpp). You can either compile the files as a library (by modifying the CMakeLists.txt) or add them to your project in your IDE. Note that you will not use the functions from io_png for example, but you need to compile them if you don't want to be annoyed by compiler errors about missing functions.
Clean (but longer) way:
you have to ignore / remove all the files that also contain the I/O part, since OpenCV can take care of them. Then you can also look for functions that are already implemented in OpenCV, such as applying an affine transform, SVD... and progressively replace them by their OpenCV counterpart.