Sponsored links: Algebra eBooks
 

Related

fullmap-lambda

fullmap(lambda([x],f(...

Calculate

fullmap-infix

infix("|");

"|"(p,[x]):=fullmap(f...

p|[a,b,c,d,e];

Calculate

fullmap-lambda

fullmap(lambda([x],f(...

Calculate

fullmap-infix

infix("|");

"|"(p,[x]):=fullmap(f...

p|[a,b,c,d,e];

Calculate

fullmap

Run Example
(%i1)val: 4;
(%o1)                                  4
(%i2) errordata: matrix([1,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]);
                                [ 1  0  0  0 ]
                                [            ]
                                [ 0  0  0  0 ]
(%o2)                           [            ]
                                [ 0  0  0  0 ]
                                [            ]
                                [ 0  0  0  0 ]
(%i3) forward: matrix([1,1,1,1],[2,1,-1,-2],[1,-1,-1,1],[1,-2,2,-1]);
                             [ 1   1    1    1  ]
                             [                  ]
                             [ 2   1   - 1  - 2 ]
(%o3)                        [                  ]
                             [ 1  - 1  - 1   1  ]
                             [                  ]
                             [ 1  - 2   2   - 1 ]
(%i4) inversedct: matrix([1,1,1,1],[1,0.5,-0.5,-1],[1,-1,-1,1],[0.5,-1,1,-0.5]);
                          [  1    1     1      1   ]
                          [                        ]
                          [  1   0.5  - 0.5   - 1  ]
(%o4)                     [                        ]
                          [  1   - 1   - 1     1   ]
                          [                        ]
                          [ 0.5  - 1    1    - 0.5 ]
(%i5) transformed : forward . errordata . transpose(forward);
                                [ 1  2  1  1 ]
                                [            ]
                                [ 2  4  2  2 ]
(%o5)                           [            ]
                                [ 1  2  1  1 ]
                                [            ]
                                [ 1  2  1  1 ]
(%i6) m: matrix([13107, 5243, 8066],[11916,4660,7490],[10082,4194,6554],[9362,3647,5825],[8192,3355,5243],[7282,2893,4559]);
                             [ 13107  5243  8066 ]
                             [                   ]
                             [ 11916  4660  7490 ]
                             [                   ]
                             [ 10082  4194  6554 ]
(%o6)                        [                   ]
                             [ 9362   3647  5825 ]
                             [                   ]
                             [ 8192   3355  5243 ]
                             [                   ]
                             [ 7282   2893  4559 ]
(%i7) v: matrix([10,16,13],[11,18,14],[13,20,16],[14,23,18],[16,25,20],[18,29,23]);
                                [ 10  16  13 ]
                                [            ]
                                [ 11  18  14 ]
                                [            ]
                                [ 13  20  16 ]
(%o7)                           [            ]
                                [ 14  23  18 ]
                                [            ]
                                [ 16  25  20 ]
                                [            ]
                                [ 18  29  23 ]
(%i8) QP: 6;
(%o8)                                  6
(%i9) i: mod(QP, 6) + 1;
(%o9)                                  1
(%i10) m0: matrix([m[i,1],m[i,3],m[i,1],m[i,3]],[m[i,3],m[i,2],m[i,3],m[i,2]],[m[i,1],m[i,3],m[i,1],m[i,3]],[m[i,3],m[i,2],m[i,3],m[i,2]]);
                         [ 13107  8066  13107  8066 ]
                         [                          ]
                         [ 8066   5243  8066   5243 ]
(%o10)                   [                          ]
                         [ 13107  8066  13107  8066 ]
                         [                          ]
                         [ 8066   5243  8066   5243 ]
(%i11) v0: matrix([v[i,1],v[i,3],v[i,1],v[i,3]],[v[i,3],v[i,2],v[i,3],v[i,2]],[v[i,1],v[i,3],v[i,1],v[i,3]],[v[i,3],v[i,2],v[i,3],v[i,2]]);
                              [ 10  13  10  13 ]
                              [                ]
                              [ 13  16  13  16 ]
(%o11)                        [                ]
                              [ 10  13  10  13 ]
                              [                ]
                              [ 13  16  13  16 ]
(%i12) roundingconst: floor((2^(floor(QP/6) + 15)) / 6);
(%o12)                               10922
(%i13) quantshift: (2^(floor(QP/6) + 15));
(%o13)                               65536
(%i14) result: ((abs(transformed * m0) + roundingconst) / quantshift), numer;
(%o14) 
     [ 0.36665344238281  0.41281127929688  0.36665344238281  0.28973388671875 ]
     [                                                                        ]
     [ 0.41281127929688  0.48666381835938  0.41281127929688   0.32666015625   ]
     [                                                                        ]
     [ 0.36665344238281  0.41281127929688  0.36665344238281  0.28973388671875 ]
     [                                                                        ]
     [ 0.28973388671875   0.32666015625    0.28973388671875  0.24665832519531 ]
(%i15) quantized: floor(result) * fullmap(signum, ((transformed * m0)));
                                [ 0  0  0  0 ]
                                [            ]
                                [ 0  0  0  0 ]
(%o15)                          [            ]
                                [ 0  0  0  0 ]
                                [            ]
                                [ 0  0  0  0 ]
(%i16) dequantized: quantized * v0 * 2^floor(QP/6);
                                [ 0  0  0  0 ]
                                [            ]
                                [ 0  0  0  0 ]
(%o16)                          [            ]
                                [ 0  0  0  0 ]
                                [            ]
                                [ 0  0  0  0 ]
(%i17) inversetransformed: transpose(inversedct) . dequantized . inversedct;
                            [ 0.0  0.0  0.0  0.0 ]
                            [                    ]
                            [ 0.0  0.0  0.0  0.0 ]
(%o17)                      [                    ]
                            [ 0.0  0.0  0.0  0.0 ]
                            [                    ]
                            [ 0.0  0.0  0.0  0.0 ]
(%i18) rescaled: floor((inversetransformed + 32) / 64);
                                [ 0  0  0  0 ]
                                [            ]
                                [ 0  0  0  0 ]
(%o18)                          [            ]
                                [ 0  0  0  0 ]
                                [            ]
                                [ 0  0  0  0 ]
(%i19) 
Run Example
QP: 30;
(%o1)                                 30
(%i2) i: mod(QP, 6) + 1;
(%o2)                                  1
(%i3) m: matrix([13107, 5243, 8066],[11916,4660,7490],[10082,4194,6554],[9362,3647,5825],[8192,3355,5243],[7282,2893,4559]);
                             [ 13107  5243  8066 ]
                             [                   ]
                             [ 11916  4660  7490 ]
                             [                   ]
                             [ 10082  4194  6554 ]
(%o3)                        [                   ]
                             [ 9362   3647  5825 ]
                             [                   ]
                             [ 8192   3355  5243 ]
                             [                   ]
                             [ 7282   2893  4559 ]
(%i4) v: matrix([10,16,13],[11,18,14],[13,20,16],[14,23,18],[16,25,20],[18,29,23]);
                                [ 10  16  13 ]
                                [            ]
                                [ 11  18  14 ]
                                [            ]
                                [ 13  20  16 ]
(%o4)                           [            ]
                                [ 14  23  18 ]
                                [            ]
                                [ 16  25  20 ]
                                [            ]
                                [ 18  29  23 ]
(%i5) m0: matrix([m[i,1],m[i,3],m[i,1],m[i,3]],[m[i,3],m[i,2],m[i,3],m[i,2]],[m[i,1],m[i,3],m[i,1],m[i,3]],[m[i,3],m[i,2],m[i,3],m[i,2]]);
                         [ 13107  8066  13107  8066 ]
                         [                          ]
                         [ 8066   5243  8066   5243 ]
(%o5)                    [                          ]
                         [ 13107  8066  13107  8066 ]
                         [                          ]
                         [ 8066   5243  8066   5243 ]
(%i6) v0: matrix([v[i,1],v[i,3],v[i,1],v[i,3]],[v[i,3],v[i,2],v[i,3],v[i,2]],[v[i,1],v[i,3],v[i,1],v[i,3]],[v[i,3],v[i,2],v[i,3],v[i,2]]);
                              [ 10  13  10  13 ]
                              [                ]
                              [ 13  16  13  16 ]
(%o6)                         [                ]
                              [ 10  13  10  13 ]
                              [                ]
                              [ 13  16  13  16 ]
(%i7) col(m0,1);
                                   [ 13107 ]
                                   [       ]
                                   [ 8066  ]
(%o7)                              [       ]
                                   [ 13107 ]
                                   [       ]
                                   [ 8066  ]
(%i8) errordata: matrix([0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]) - 1;
                            [ - 1  - 1  - 1  - 1 ]
                            [                    ]
                            [ - 1  - 1  - 1  - 1 ]
(%o8)                       [                    ]
                            [ - 1  - 1  - 1  - 1 ]
                            [                    ]
                            [ - 1  - 1  - 1  - 1 ]
(%i9) errordata: matrix([58,64,51,58],[52,64,56,66],[62,63,61,64],[59,51,63,69]);
                              [ 58  64  51  58 ]
                              [                ]
                              [ 52  64  56  66 ]
(%o9)                         [                ]
                              [ 62  63  61  64 ]
                              [                ]
                              [ 59  51  63  69 ]
(%i10) forward: matrix([1,1,1,1],[2,1,-1,-2],[1,-1,-1,1],[1,-2,2,-1]);
                             [ 1   1    1    1  ]
                             [                  ]
                             [ 2   1   - 1  - 2 ]
(%o10)                       [                  ]
                             [ 1  - 1  - 1   1  ]
                             [                  ]
                             [ 1  - 2   2   - 1 ]
(%i11) inversedct: matrix([1,1,1,1],[1,0.5,-0.5,-1],[1,-1,-1,1],[0.5,-1,1,-0.5]);
                          [  1    1     1      1   ]
                          [                        ]
                          [  1   0.5  - 0.5   - 1  ]
(%o11)                    [                        ]
                          [  1   - 1   - 1     1   ]
                          [                        ]
                          [ 0.5  - 1    1    - 0.5 ]
(%i12) transformed : forward . errordata . transpose(forward);
                          [ 961   - 41   15   - 48  ]
                          [                         ]
                          [ - 34   72   - 30  - 104 ]
(%o12)                    [                         ]
                          [ - 15   3     15    24   ]
                          [                         ]
                          [  13    81   - 5     8   ]
(%i13) roundingconst: floor((2^(floor(QP/6) + 15)) / 6);
(%o13)                              174762
(%i14) quantshift: (2^(floor(QP/6) + 15));
(%o14)                              1048576
(%i15) quantized: floor((abs(transformed * m0) + roundingconst) / quantshift) * fullmap(signum, ((transformed * m0)));
                                [ 12  0  0  0 ]
                                [             ]
                                [ 0   0  0  0 ]
(%o15)                          [             ]
                                [ 0   0  0  0 ]
                                [             ]
                                [ 0   0  0  0 ]
(%i16) dequantized: quantized * v0 * 2^floor(QP/6);
                               [ 3840  0  0  0 ]
                               [               ]
                               [  0    0  0  0 ]
(%o16)                         [               ]
                               [  0    0  0  0 ]
                               [               ]
                               [  0    0  0  0 ]
(%i17) dct2x2: matrix([1, 1], [1, -1]);
                                  [ 1   1  ]
(%o17)                            [        ]
                                  [ 1  - 1 ]
(%i18) DCs: matrix([0,30],[-100,10]) + transformed[1,1];
                                 [ 961  991 ]
(%o18)                           [          ]
                                 [ 861  971 ]
(%i19) DCsTransformed: dct2x2 . DCs . dct2x2;
                                [ 3784  - 140 ]
(%o19)                          [             ]
                                [ 120    80   ]
(%i20) DCSigns: fullmap(signum, DCsTransformed);
                                  [ 1  - 1 ]
(%o20)                            [        ]
                                  [ 1   1  ]
(%i21) DCsQuantized: floor((abs(DCsTransformed) * m0[1,1] + (2 * roundingconst)) / (quantshift*2));
                                   [ 23  1 ]
(%o21)                             [       ]
                                   [ 0   0 ]
(%i22) DCsDequantized: DCsQuantized * v0[1,1] * 2^(floor(QP/6)-1) * DCSigns;
                                [ 3680  - 160 ]
(%o22)                          [             ]
                                [  0      0   ]
(%i23) DCsInverseTransformed: dct2x2 . DCsDequantized . dct2x2;
                                [ 3520  3840 ]
(%o23)                          [            ]
                                [ 3520  3840 ]
(%i24) DCsInverseTransformed;
                                [ 3520  3840 ]
(%o24)                          [            ]
                                [ 3520  3840 ]
(%i25) dequantized[1,1]:DCsInverseTransformed[1,1];
(%o25)                               3520
(%i26) inversetransformed: transpose(inversedct) . dequantized . inversedct;
                      [ 3520.0  3520.0  3520.0  3520.0 ]
                      [                                ]
                      [ 3520.0  3520.0  3520.0  3520.0 ]
(%o26)                [                                ]
                      [ 3520.0  3520.0  3520.0  3520.0 ]
                      [                                ]
                      [ 3520.0  3520.0  3520.0  3520.0 ]
(%i27) rescaled: floor((inversetransformed + 32) / 64);
                              [ 55  55  55  55 ]
                              [                ]
                              [ 55  55  55  55 ]
(%o27)                        [                ]
                              [ 55  55  55  55 ]
                              [                ]
                              [ 55  55  55  55 ]
(%i28) 
Run Example
transformed: matrix([961,-41,15,-48],[-34,72,-30,-104],[-15,3,15,24],[13,81,-5,8]);
                          [ 961   - 41   15   - 48  ]
                          [                         ]
                          [ - 34   72   - 30  - 104 ]
(%o1)                     [                         ]
                          [ - 15   3     15    24   ]
                          [                         ]
                          [  13    81   - 5     8   ]
(%i2) val: 4;
(%o2)                                  4
(%i3) errordata: transpose(matrix([0,0,val,0],[0,0,val,0],[0,0,val,0],[0,0,val,0]));
                                [ 0  0  0  0 ]
                                [            ]
                                [ 0  0  0  0 ]
(%o3)                           [            ]
                                [ 4  4  4  4 ]
                                [            ]
                                [ 0  0  0  0 ]
(%i4) forward: matrix([1,1,1,1],[2,1,-1,-2],[1,-1,-1,1],[1,-2,2,-1]);
                             [ 1   1    1    1  ]
                             [                  ]
                             [ 2   1   - 1  - 2 ]
(%o4)                        [                  ]
                             [ 1  - 1  - 1   1  ]
                             [                  ]
                             [ 1  - 2   2   - 1 ]
(%i5) inversedct: matrix([1,1,1,1],[1,0.5,-0.5,-1],[1,-1,-1,1],[0.5,-1,1,-0.5]);
                          [  1    1     1      1   ]
                          [                        ]
                          [  1   0.5  - 0.5   - 1  ]
(%o5)                     [                        ]
                          [  1   - 1   - 1     1   ]
                          [                        ]
                          [ 0.5  - 1    1    - 0.5 ]
(%i6) transformed : forward . errordata . transpose(forward);
                               [  16   0  0  0 ]
                               [               ]
                               [ - 16  0  0  0 ]
(%o6)                          [               ]
                               [ - 16  0  0  0 ]
                               [               ]
                               [  32   0  0  0 ]
(%i7) m: matrix([13107, 5243, 8066],[11916,4660,7490],[10082,4194,6554],[9362,3647,5825],[8192,3355,5243],[7282,2893,4559]);
                             [ 13107  5243  8066 ]
                             [                   ]
                             [ 11916  4660  7490 ]
                             [                   ]
                             [ 10082  4194  6554 ]
(%o7)                        [                   ]
                             [ 9362   3647  5825 ]
                             [                   ]
                             [ 8192   3355  5243 ]
                             [                   ]
                             [ 7282   2893  4559 ]
(%i8) v: matrix([10,16,13],[11,18,14],[13,20,16],[14,23,18],[16,25,20],[18,29,23]);
                                [ 10  16  13 ]
                                [            ]
                                [ 11  18  14 ]
                                [            ]
                                [ 13  20  16 ]
(%o8)                           [            ]
                                [ 14  23  18 ]
                                [            ]
                                [ 16  25  20 ]
                                [            ]
                                [ 18  29  23 ]
(%i9) QP: 0;
(%o9)                                  0
(%i10) i: mod(QP, 6) + 1;
(%o10)                                 1
(%i11) m0: matrix([m[i,1],m[i,3],m[i,1],m[i,3]],[m[i,3],m[i,2],m[i,3],m[i,2]],[m[i,1],m[i,3],m[i,1],m[i,3]],[m[i,3],m[i,2],m[i,3],m[i,2]]);
                         [ 13107  8066  13107  8066 ]
                         [                          ]
                         [ 8066   5243  8066   5243 ]
(%o11)                   [                          ]
                         [ 13107  8066  13107  8066 ]
                         [                          ]
                         [ 8066   5243  8066   5243 ]
(%i12) v0: matrix([v[i,1],v[i,3],v[i,1],v[i,3]],[v[i,3],v[i,2],v[i,3],v[i,2]],[v[i,1],v[i,3],v[i,1],v[i,3]],[v[i,3],v[i,2],v[i,3],v[i,2]]);
                              [ 10  13  10  13 ]
                              [                ]
                              [ 13  16  13  16 ]
(%o12)                        [                ]
                              [ 10  13  10  13 ]
                              [                ]
                              [ 13  16  13  16 ]
(%i13) roundingconst: floor((2^(floor(QP/6) + 15)) / 6);
(%o13)                               5461
(%i14) quantshift: (2^(floor(QP/6) + 15));
(%o14)                               32768
(%i15) transformed * m0;
                             [  209712   0  0  0 ]
                             [                   ]
                             [ - 129056  0  0  0 ]
(%o15)                       [                   ]
                             [ - 209712  0  0  0 ]
                             [                   ]
                             [  258112   0  0  0 ]
(%i16) abs(transformed * m0), simp;
                              [ 209712  0  0  0 ]
                              [                 ]
                              [ 129056  0  0  0 ]
(%o16)                        [                 ]
                              [ 209712  0  0  0 ]
                              [                 ]
                              [ 258112  0  0  0 ]
(%i17) (abs(transformed * m0) + roundingconst);
                         [ 215173  5461  5461  5461 ]
                         [                          ]
                         [ 134517  5461  5461  5461 ]
(%o17)                   [                          ]
                         [ 215173  5461  5461  5461 ]
                         [                          ]
                         [ 263573  5461  5461  5461 ]
(%i18) result: ((abs(transformed * m0) + roundingconst) / quantshift), numer;
(%o18) 
    [ 6.566558837890625  0.16665649414063  0.16665649414063  0.16665649414063 ]
    [                                                                         ]
    [ 4.105133056640625  0.16665649414063  0.16665649414063  0.16665649414063 ]
    [                                                                         ]
    [ 6.566558837890625  0.16665649414063  0.16665649414063  0.16665649414063 ]
    [                                                                         ]
    [ 8.043609619140625  0.16665649414063  0.16665649414063  0.16665649414063 ]
(%i19) quantized: floor(result) * fullmap(signum, ((transformed * m0)));
                               [  6   0  0  0 ]
                               [              ]
                               [ - 4  0  0  0 ]
(%o19)                         [              ]
                               [ - 6  0  0  0 ]
                               [              ]
                               [  8   0  0  0 ]
(%i20) dequantized: quantized * v0 * 2^floor(QP/6);
                               [  60   0  0  0 ]
                               [               ]
                               [ - 52  0  0  0 ]
(%o20)                         [               ]
                               [ - 60  0  0  0 ]
                               [               ]
                               [ 104   0  0  0 ]
(%i21) inversetransformed: transpose(inversedct) . dequantized . inversedct;
                      [  0.0     0.0     0.0     0.0   ]
                      [                                ]
                      [ - 10.0  - 10.0  - 10.0  - 10.0 ]
(%o21)                [                                ]
                      [ 250.0   250.0   250.0   250.0  ]
                      [                                ]
                      [  0.0     0.0     0.0     0.0   ]
(%i22) rescaled: floor((inversetransformed + 32) / 64);
                                [ 0  0  0  0 ]
                                [            ]
                                [ 0  0  0  0 ]
(%o22)                          [            ]
                                [ 4  4  4  4 ]
                                [            ]
                                [ 0  0  0  0 ]
(%i23) 

Related Help

Help for Fullmap