Approximate string matching in C? - c

I am seeking for a C library that does approximate string matching. Calculating Levenshtein distance for example. My query strings will be ~512 bytes. I know about Flamingo but it is C++.

Not a library but simple function you find here
A GPL Version

PyLevenshtein has C source and a Python wrapper: http://code.google.com/p/pylevenshtein/
Wikipedia has an article describing example implementations of Levenshtein distance: http://en.wikibooks.org/wiki/Algorithm_implementation/Strings/Levenshtein_distance#C
You might also be able to rewrite part of libraries to allow C code to call into them (via extern C calls).

Related

In what library is dgesvd_?

I'm trying to use the function dgesvd_() in a code and just can't find the library I have to include in order to the compiler to detect it!
I've only discovered some LAPACK or something like that but couldn't see includes or relevant information anywhere.
dgesvd computes the singular value decomposition (SVD) of a real matrix. It is a part of LAPACK. LAPACK is not really a library but an interface for numerical algebra functions. The standard implementation is the one provided by Netlib LAPACK. However, the Intel MKL also implement this (more efficiently than the one of Netlib). LAPACKE is a C interface of the FORTRAN one provided by the Netlib implementation. It provides a header than can be used for C project to call LAPACK functions (linked at runtime). You could use it in your C project as long as you link a LAPACK-compatible library.

Calculating the Chi-square CDF in C

I'm very new to coding in C, and I'm working on calculating the CDF for a chi-square distribution given a value and the degrees of freedom. Is there a function or a library that does this or will I need to write this code myself?
Any help would be appreciated
If I am right you can use the GNU Scientific Library. Look for the function gsl_ran_chisq, which returns a random value from a Chi-square distribution provided a number of degrees of freedom.
You can check the C functions related to chi-square and many other distributions on this link. Simply install the library. Link to the lib's home page can also be found here.
I hope I have helped.

How to write GMM (Gaussian Mixture Model) in C?

How can I write GMM (Gaussian Mixture Model) in C. There are some implementations in Matlab but I am looking for some documentation about it and example code in C not in C++.
OpenCV has an implementation of a GMM that is used for their GrabCut implementation.
You can find it for example here.
edit: I just noticed you were looking for an implementation in C. The OpenCV implementation is using C++. But maybe you can use it as a starting point.
Here you can find an implementation in C:
https://engineering.purdue.edu/~bouman/software/cluster/
How about the mixture model in Apophenia?
There is a GMM implementation available in vlfeat, a C library for computer vision. https://www.vlfeat.org/api/gmm.html

Singular Value Decomposition simple code in c

I am looking for Singular Value Decomposition (SVD) code in C, would you please help me?
I found many sources but I cannot run them, I am looking for a version of SVD code that provide all 3 matrix of S, V and U for me.
You can use the Numerical recipies code for that
svdcmp.c reference. Actually in my case I found more accurate the openCV one, but both work fine.
Use one of the libraries listed at the Wiki page: comparison of linear algebra libraries. Look under the "SVD" column to make sure algorithm is supported (even vast majority of the libraries do support SVD).
Don't write it yourself, don't deal with trying to build someone else's source. Use a library that provides this function for you. There's probably already one available on your target platform.
Specifically, use the industry-standard LAPACK library or use the GSL or whatever other linear algebra library you want. They all have an SVD implementation.

Recursive Descent Parser for C

I'm looking for a parser for C. Here is what I need:
Written in C (not C++).
Handwritten (not generated).
BSD or similarly permissive license.
Capable of nontrivially parsing itself (can be a subset of C).
It can be part of a project as long as it's decoupled so that I can pull out the parser.
Is there an existing parser that fulfills these requirements?
If you don't need C99, then lcc is a slam dunk:
It is documented in a very clear, well-written book.
Techniques used for recursive-descent parsing of operators with precedence are well documented in an article and technical report by Dave Hanson.
Clear, handwritten ANSI C code.
One potential downside is that the lcc parser does not build an abstract-syntax treeā€”it goes straight from parsing to intermediate code.
If you must have C99 then I think tinycc (tcc) is your best bet.
How about Sparse?
You could try TCC. It's licensed under the Lesser GPL.
It seems that nwcc sufficiently agrees with your requirements.
Good c compiler is present at this location. Simple and accessible.
https://github.com/rui314/8cc
GCC has one in gcc/c-parser.c.
Check elsa, it uses the Generalized LR algorithm.
Its main use is for C++, but it also parses C code.
Check on its page, on the section called "How much C can Elsa parse?" which says it can parse most C programs, including the Linux kernel.
It's released under a BSD license.
Here is a recursive descent parser I ported to C:
http://www.gabotronics.com/resources/recursive-descent-parser.htm

Resources