fanf: (Default)
[personal profile] fanf

So I needed some Lua functions to extract bit fields from an integral value, specifically struct stat.st_mode. Lua only has floating point numbers, and its standard library doesn't extend beyond ANSI C. So I wrote the following. (Note that a % b == a - floor(a/b)*b.)

   function mask(lobit, hibit, num)
      local toolo = num % 2^lobit
      return (num - toolo) % 2^hibit
   end

   function bit(bit, num)
      return num / 2^bit % 2 >= 1
   end

Date: 2008-05-07 10:31 (UTC)
From: [identity profile] pjc50.livejournal.com
http://portal.acm.org/citation.cfm?id=806321&dl= , possibly?

I remember his approach to fast multiplication (FFT, convolve, FFT); I'd guess that he had some fast method for computing 1/x, which would make a/b as fast as a*(1/b).

Date: 2008-05-07 16:33 (UTC)
From: [identity profile] happydisciple.livejournal.com
[...] his approach to fast multiplication (FFT, convolve, FFT); [...]
Wuh?

Whenever I need to do a convolution or, more likely, a correlation/autocorrelation, I tend to go FFT, multiply, FFT. In what case/by what algorithm is a direct convolution faster than multiplication?

June 2025

S M T W T F S
1234567
8 91011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated 2025-06-24 22:00
Powered by Dreamwidth Studios