[mus422] BFP Quantization test

Marina Bosi mbosi at stanford.edu
Wed Jan 27 12:43:57 PST 2010


Colin,

 

Please find below a "help" file on how to use quantize.pyc and some
numbers to check your BFP code.  

 

Hope this helps,

Marina

 

Help on module quantize:

 

NAME

    quantize - quantize.py -- routines to quantize and dequantize floating
point values between -1.0 and 1.0 ("signed fractions")

 

FILE

    c:\users\marina\desktop\python\2010\test\quantize.pyc

 

FUNCTIONS

    Dequantize(scale, mantissa, nScaleBits=3, nMantBits=5)

        Returns a signed fraction for block floating point scale and
mantissa given specified scale and mantissa bits

    

    DequantizeUniform(code, nBits=16)

        Uniformly dequantizes nBits-long code into a signed fraction

    

    Mantissa(aNumber, scale, nScaleBits=3, nMantBits=5)

        Returns the block-floating point mantissa for signed fraction
aNumber given scale factor and numbers of scale and mantissa bits

    

    QuantizeUniform(aNumber, nBits=16)

        Uniformly quantize signed fraction aNumber with nBits

    

    ScaleFactor(aNumber, nScaleBits=3, nMantBits=5)

        Return the scale factor for a signed fraction aNumber given
nScaleBits scale bits and nMantBits mantissa bits

    

    vDequantize(scale, mantissaVec, nScaleBits=3, nMantBits=5)

        Returns vector of signed fraction numbers for block floating point
scale and vector of mantissas mantissa given specified scale and mantissa
bits

    

    vDequantizeUniform(codeVec, nBits=16)

        Uniformly dequantizes nBits-long vector of codes codeVec into
vector of signed fraction values

    

    vMantissa(aNumberVec, scale, nScaleBits=3, nMantBits=5)

        Returns vector of block-floating point mantissas for vector of
signed fraction numbers given scale factor and numbers of scale and
mantissa bits

    

    vQuantizeUniform(aNumberVec, nBits=16)

        Uniformly quantize vector aNumberVec of signed fraction numbers
with nBits

 

 

None

Uniform Quantization with 8 bits: (not vectorized)

 

            Input Code Output

            0.82     105      0.823529411765

 

Uniform Quantization with 8 bits: (vectorized)

 

 

            Inputs:

            [-1.    -0.97  -0.41   0.     0.008  0.51   0.82   0.999  1.
]

 

            Codes:  [255 252 180   0   1  65 105 127 127]

 

            Outputs:

            [-0.99607843 -0.97254902 -0.40784314  0.          0.00784314
0.50980392

  0.82352941  0.99607843  0.99607843]

 

Block Floating Point with 3 scale bits and 5 mantissa bits: (each number
is a block)

 

            Input Scale Mant Output

            -1.0      0          31        -0.968986568987

            Input Scale Mant Output

            -0.97    0          31        -0.968986568987

            Input Scale Mant Output

            -0.41    1          29        -0.421978021978

            Input Scale Mant Output

            0.0       7          0          0.0

            Input Scale Mant Output

            0.008   6          8          0.00830280830281

            Input Scale Mant Output

            0.51     0          8          0.53137973138

            Input Scale Mant Output

            0.82     0          13        0.843956043956

            Input Scale Mant Output

            0.999   0          15        0.968986568987

            Input Scale Mant Output

            1.0       0          15        0.968986568987

 

Block Floating Point with 3 scale bits and 5 mantissa bits: (all numbers
in a single block)

 

 

            Inputs:

            [-1.    -0.97  -0.41   0.     0.008  0.51   0.82   0.999  1.
]

 

            Scale: 0

 

            Mantissas:  [31 31 22  0  0  8 13 15 15]

 

            Outputs:

            [-0.96898657 -0.96898657 -0.40634921  0.          0.
0.53137973

  0.84395604  0.96898657  0.96898657]

 

 

 

 

 

-----Original Message-----
From: Colin Raffel [mailto:craffel at ccrma.stanford.edu] 
Sent: Tuesday, January 26, 2010 10:45 PM
To: Marina Bosi
Subject: quantize.pyc

 

Hi Professor Bosi, I am trying to quadruple check my quantizer code  

and I was wondering how to call the block floating point quantizer and  

dequantizer in the quantize.pyc file you supplied us with.  If there  

isn't that functionality in the file, do you have one on hand that I  

can check my quantizer against?  Thanks, see you Friday!

 

-Colin

 

 

Marina Bosi

Consulting Professor, Department of Music

Stanford University

 

Computer Center for Research in Music and Acoustics

The Knoll,  660 Lomita Court

Stanford, California 94305-8180, USA

http://ccrma.stanford.edu

mbosi at stanford.edu

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cm-mail.stanford.edu/pipermail/422/attachments/20100127/77e8fa2f/attachment-0001.html 


More information about the 422 mailing list