Could someone explain the meaning of linker flag "-lm". Which library is being represented by the letter "m". If "m" is not a library name what is it then.
It depends on your system, but traditionally, libm is the math library. Here is where you'll find things like trig functions, square root, and other floating point operations.
Related
I'm looking into using GLPK to solve a ILP. Some of my constraints have the following form
I * W <= A
Where I is the variable and W and A are constants. W though, could be very, very large. An example value might be 2251799813685248, and may be even larger. Therefore, if GLPK uses standard primitives under the hood, there could be an issue.
So my question is, is GLPK subject to machine precision (i.e. 32 bit) or does GLPK use variable precision (i.e. mathematical ints without memory bound limits)? If not, are there any other open source packages that support variable precision?
If you configure --with-gmp when you build GLPK, it'll use the
GNU Multiple-Precision library
GMP; download, build that first. (configure -h:
--with-gmp: use GNU MP bignum library [[default=no]]
I don't know of a problem where GMP make a difference; please let us know.
I'd like to perform FFT over an array of BigFloats in Julia, but so far I couldn't make it possible. I found FFTW.jl and followed the instructions in their docs (importall FFTW, etc.). Sadly this did not help and I'm still getting ERROR: type BigFloat not supported when running a command like fft([BigFloat(1.0)]).
Did anybody experience (and hopefully overcome) similar issues?
FFTW.jl is a wrapper to the C library FFTW which cannot handle BigFloats. You need to find a pure-Julia code, like this one in FastTransforms.jl.
I'm looking for a 64-bit fixed-point (32,32) library for one of my C implementations.
Similar to this one http://code.google.com/p/libfixmath/
Need support for standard math.h operation.
Did anyone see such implementations?
fixedptc seems to be what you look for. It is a C, header-only and integer-only library for fixed point operations, located at http://www.sourceforge.net/projects/fixedptc
Bitwidth is settable through defines. In your case, you want to compile with -DFIXEDPT_BITS=64 -DFIXED_WBITS=32 to get a (32,32) fixed point number format.
Implemented functions are conversion to string, multiplication, division, square root, sine, cosine, tangent, exponential, power, natural logarithm and arbitrary-base logarithm.
does anyone know how to get symbols for the real and complex field or the projective plane with Doxygen, i.o.w symbols such as IR, IC, IP, etc. ?
I tried \f$ \field{R} \f$ for instance, but it is not recognized.
Thanks a lot for help,
G.
Don't the standard math font commands work in Doxygen? Things like mathbf, mathcal and mathbb? Is one of those appropriate for your needs?
I'm working with large numbers that I can't have rounded off. Using Lua's standard math library, there seem to be no convenient way to preserve precision past some internal limit. I also see there are several libraries that can be loaded to work with big numbers:
http://oss.digirati.com.br/luabignum/
http://www.tc.umn.edu/~ringx004/mapm-main.html
http://lua-users.org/lists/lua-l/2002-02/msg00312.html (might be identical to #2)
http://www.gammon.com.au/scripts/doc.php?general=lua_bc (but I can't find any source)
Further, there are many libraries in C that could be called from Lua, if the bindings where established.
Have you had any experience with one or more of these libraries?
Using lbc instead of lmapm would be easier because lbc is self-contained.
local bc = require"bc"
s=bc.pow(2,1000):tostring()
z=0
for i=1,#s do
z=z+s:byte(i)-("0"):byte(1)
end
print(z)
I used Norman Ramsey's suggestion to solve Project Euler problem #16. I don't think it's a spoiler to say that the crux of the problem is calculating a 303 digit integer accurately.
Here are the steps I needed to install and use the library:
Lua needs to be built with dynamic loading enabled. I use Cygwin, but I changed PLAT in src/Makefile to be linux. The default, none, doesn't enable dynamic loading.
The MAMP needs to be built and installed somewhere that your C compiler can find it. I put libmapm.a in /usr/local/lib/. Next m_apm.h and m_apm_lc.h went to /usr/local/include/.
The makefile for lmamp needs to be altered to the correct location of the Lua and MAMP libraries. For me, that means uncommenting the second declaration of LUA, LUAINC, LUALIB, and LUABIN and editing the declaration of MAMP.
Finally, mapm.so needs to be placed somewhere that Lua will find it. I put it at /usr/local/lib/lua/5.1/.
Thank you all for the suggestions!
The lmapm library by Luiz Figueiredo, one of the authors of the Lua language.
I can't really answer, but I will add LGMP, a GMP binding. Not used.
Not my field of expertise, but I would expect the GNU multiple precision arithmetic library to be quite a standard here, no?
Though not arbitrary precision, Lua decNumber, a Lua 5.1 wrapper for IBM decNumber, implements the proposed General Decimal Arithmetic standard IEEE 754r. It has the Lua 5.1 arithmetic operators and more, full control over rounding modes, and working precision up to 69 decimal digits.
There are several libraries for the problem, each one with your advantages
and disadvantages, the best choice depends on your requeriments. I would say
lbc is a good first pick if it
fulfills your requirements or any other by Luiz Figueiredo. For the most efficient one I guess would be any using GMP bindings as GMP is a standard C library for dealing with large integers and is very well optimized.
Nevertheless in case you are looking for a pure Lua one, lua-bint
library could be an option for dealing with big integers,
I wouldn't say it's the best because there are more efficient
and complete ones such the ones mentioned above, but usually they requires compiling C code
or can be troublesome to setup. However when comparing pure Lua big integer libraries
and depending in your use case it could perhaps be an efficient choice. The library is documented,
code fully covered by tests and have many examples. But take this recommendation with grant of
salt because I am the library author.
To install you can use luarocks if you already have it in your computer or simply download the
bint.lua
file in your project, as it has no other dependencies other than requiring Lua 5.3+.
Here is a small example using it to solve the problem #16 from Project Euler
(mentioned in previous answers):
local bint = require 'bint'(1024)
local n = bint(1) << 1000
local digits = tostring(n)
local sum = 0
for i=1,#digits do
sum = sum + tonumber(digits:sub(i,i))
end
print(sum) -- should output 1366