c++ petsc matrix inversion - c++

can any one share with me a few different example of dense matrix inversion's with Petsc. I searched the web and could only find algorithm's and no solid examples with code. Thank you

In their documentation. They seems to say which function to call when.
You can find it here.
Also, I found a manual that provides multiples code example that you might want to look at.
Hope it helps!

Related

Mahout 0.9 K-Means mapReduce analysis of the algorithm

I have been checking the algorithm of Mahout 0.9 k-means using MapReduce and I would like to know where can I check the code of what is happening inside the map function and in the reducer?
I was using debugging using NetBeans and I was not able to find what is exactly implemented in the Map and Reduce functions...
The reason what I am doing this is because I would like to know what is exactly implemented in the version of Mahout 0.9 in order to see which parts where optimized on the K-Means mapReduce algorithm.
If somebody knows which research paper the Mahout K-means were based on, that would also helped me a lot.
Thank you so much!
Best regards!
Download source code for mahout-core. Search for java file org.apache.mahout.clustering.kmeans.KMeansDriver.
In this java file search for line ClusterIterator.iterateMR(conf, input, priorClustersPath, output, maxIterations);
iterateMR function in class org.apache.mahout.clustering.iterator.ClusterIterator is the class which defines all configuration required for Map Reduce.
org.apache.mahout.clustering.iterator.CIMapper and org.apache.mahout.clustering.iterator.CIReducer are the Map reduce classes you are looking for.
Hope this helps!! :)
However, I do not know which research paper is implemented.
K-means (more precisely, Lloyds algorithm) is naively parallel. I doubt there is a paper discussing the implementation used by Mahout, because it's the obvious way to do so. There is absolutely no trick involved:
Lloyds algorithm consists mostly of a sum, and sums are trivially to parallelize.
Unfortunately (like much of Hadoop), Mahout is 10 layers thick abstraction. Which doesn't yield the best performance, but in particular makes it also really hard to dig through all the code and meta-code to the actual implementation. See the other answere here for pointers to the source code fragments scattered in a dozen classes.
When playing around with Mahout, make sure to also include non-Hadoop implementations of k-means in your experiments. You will be surprised how often they A) outperform Mahout, and B) provide better results.

Student's T-distribution in C++

I need to use the equivalent of Excel's TINV function in a C++ code with no statistics library linked to it.
The problem is I don't know the maths behind Student's law.
Do you think it will be reasonable to reimplement this function from scratch without using a statistics library?
I don't have access to C++11, in that case I would use std::student_t_distribution.
If yes, please provide me references to code it.
If no, do you know a lightweight library that provides it?
Thank you.
Boost has a math library with statistics functions. Here is an example on how to use it for the student's t-test
http://www.boost.org/doc/libs/1_43_0/libs/math/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/st_eg/two_sample_students_t.html
Given the lack to this tool means you may have to write one. I'm already assuming that you looked and could not find one. The math isn't that bad though. It's just testing to see if two observed distributions have the same mean. www.r-tutor.com has a good tutorial on this distribution. Math World shows the deeper context. Happy hunting.
It's too much work without using a statistics library.
What I am gonna do is generate numeric values in Excel for the range of values I need and copy it in an array in my code.
Hardcore style.

Example for llvm::CloneBasicBlock

I am trying to find an example code which uses llvm::CloneBasicBlock, but can't find it. I am having problems with PHI nodes and problem with instruction domination. So I'll appreciate any good example code which teach how to use llvm::CloneBasicBlock properly.
What's wrong with looking in the LLVM source itself? CloneBasicBlock is used in a number of places. The simplest is probably llvm::CloneFunctionInto; it should probably be enough to demonstrate how to correctly use the function (in terms of what arguments to pass, etc.)
A more interesting example is in llvm::LoopUnroll, which also has to deal with references from PHI nodes.

How to implement 3d kDTree build and search algorithm in c or c++?

How to implement 3d kDTree build and search algorithm in c or c++? I am wondering if we have a working code to follow
I'd like to recommend you a two good presentations to start with:
"Introduction to k-d trees"
"Lecture 6: Kd-trees and range trees".
Both give all (basic ideas behind kd-trees, short visual examples and code snippets) you need to start writing your own implementation.
Update-19-10-2021: Resources are now longer public. Thanks to #Hari for posting new links down below in the comments.
I found the publications of Vlastimil Havran very useful. His Ph.d Thesis gives a nice introduction to kd-trees and traversal algorithms. Further articles are about several improvements, e.g. how to construct kd-tree in O(nlogn). There are also a lot of implementations in different graphic libs. You should just google for it.
For an example of a 3D kd-tree implementation in C, take a look at kd3. It is not general purpose library and requires the input data to be in a specific form, but the ideas and approach should be transferable.
Disclosure: I am the author of kd3.
Disclaimer: It was written as proof-of-concept code for an existing application and is therefore not as generic nor as well-tested as it should be. Bug reports/fixes are welcome.

opencv - confusion over functions "FindHomography" and "cvFindHomography"

I am a bit new to opencv. It seems that there are two functions "FindHomography" and "cvFindHomography" that perform exactly the same functionality. So I am quite confused over the difference between them.
Links to documentation are provided:
FindHomography, cvFindHomography
Thanks for the any help or clarification.
The difference in this case is that FindHomography belongs to the Python interface of OpenCV, and cvFindHomography belongs to the C interface.