Mou Code

Divacon Trace Output


poly

-- source -- -- polynomial evaluation, Mou 1991 Algo.4.7 xval=1 poly_b(a,x) = (v=a*x,pwr=x) -- 0th node: (v=a0*1,pwr=1), 1th node (v=a1*x^1,pwr=x^1) loc((hiv,hipwr), -- high side node data (lov,lopwr)) -- other, low-side node data, received from # corr = (lov+hiv*lopwr,lopwr*hipwr) -- in postadjust the whole RHS *= pwr, then add to the LHS -- postadjust (a1,x^1),(a2,x^1) should yield (a1,x^1),(a1+a2*x^1,x^2) poly_dc = PDC(d_lr,c_lr,id, (id,!loc) @ #(nil, last(0)), atomq, lift1(poly_b)) poly = unzip.0 @ poly_dc @ zip randAs = shuffled(3) Xs = [1] + xvec(xval, 7) -- vector join: + trace(poly, randAs, Xs) -- end source -- -- lib: polyb_lib.py -- """Helpers for polyb.dc: polynomial evaluation per Mou 1991 Algo 4.7. shuffled(N): a random permutation of [0..2**N - 1] - test input.""" import random def shuffled(N, seed=None): if seed is not None: random.seed(seed) arr = list(range(2 ** N)) random.shuffle(arr) return arr -- end lib -- -- trace: poly(([2,7,4,3,1,0,5,6], [1,1,1,1,1,1,1,1])) -- _zip -> [(2, 1),(7, 1),(4, 1),(3, 1),(1, 1),(0, 1),(5, 1),(6, 1)] poly_dc([(2, 1),(7, 1),(4, 1),(3, 1),(1, 1),(0, 1),(5, 1),(6, 1)]) divide d_lr -> ([(2, 1),(7, 1),(4, 1),(3, 1)], [(1, 1),(0, 1),(5, 1),(6, 1)]) poly_dc([(2, 1),(7, 1),(4, 1),(3, 1)]) divide d_lr -> ([(2, 1),(7, 1)], [(4, 1),(3, 1)]) poly_dc([(2, 1),(7, 1)]) divide d_lr -> ([(2, 1)], [(7, 1)]) poly_dc([(2, 1)]) ⇣ atom; basef -> [(2, 1)] poly_dc([(7, 1)]) ⇣ atom; basef -> [(7, 1)] post #(nil,last0) -> ([(2, 1)], [((7, 1), (2, 1))]) loc(((7, 1), (2, 1))) [hiv=7, hipwr=1, lov=2, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (2+7*1,1*1) post (id_, !loc) -> ([(2, 1)], [(9, 1)]) combine c_lr -> [(2, 1),(9, 1)] poly_dc([(4, 1),(3, 1)]) divide d_lr -> ([(4, 1)], [(3, 1)]) poly_dc([(4, 1)]) ⇣ atom; basef -> [(4, 1)] poly_dc([(3, 1)]) ⇣ atom; basef -> [(3, 1)] post #(nil,last0) -> ([(4, 1)], [((3, 1), (4, 1))]) loc(((3, 1), (4, 1))) [hiv=3, hipwr=1, lov=4, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (4+3*1,1*1) post (id_, !loc) -> ([(4, 1)], [(7, 1)]) combine c_lr -> [(4, 1),(7, 1)] post #(nil,last0) -> ([(2, 1),(9, 1)], [((4, 1), (9, 1)),((7, 1), (9, 1))]) loc(((4, 1), (9, 1))) [hiv=4, hipwr=1, lov=9, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (9+4*1,1*1) loc(((7, 1), (9, 1))) [hiv=7, hipwr=1, lov=9, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (9+7*1,1*1) post (id_, !loc) -> ([(2, 1),(9, 1)], [(13, 1),(16, 1)]) combine c_lr -> [(2, 1),(9, 1),(13, 1),(16, 1)] poly_dc([(1, 1),(0, 1),(5, 1),(6, 1)]) divide d_lr -> ([(1, 1),(0, 1)], [(5, 1),(6, 1)]) poly_dc([(1, 1),(0, 1)]) divide d_lr -> ([(1, 1)], [(0, 1)]) poly_dc([(1, 1)]) ⇣ atom; basef -> [(1, 1)] poly_dc([(0, 1)]) ⇣ atom; basef -> [(0, 1)] post #(nil,last0) -> ([(1, 1)], [((0, 1), (1, 1))]) loc(((0, 1), (1, 1))) [hiv=0, hipwr=1, lov=1, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (1+0*1,1*1) post (id_, !loc) -> ([(1, 1)], [(1, 1)]) combine c_lr -> [(1, 1),(1, 1)] poly_dc([(5, 1),(6, 1)]) divide d_lr -> ([(5, 1)], [(6, 1)]) poly_dc([(5, 1)]) ⇣ atom; basef -> [(5, 1)] poly_dc([(6, 1)]) ⇣ atom; basef -> [(6, 1)] post #(nil,last0) -> ([(5, 1)], [((6, 1), (5, 1))]) loc(((6, 1), (5, 1))) [hiv=6, hipwr=1, lov=5, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (5+6*1,1*1) post (id_, !loc) -> ([(5, 1)], [(11, 1)]) combine c_lr -> [(5, 1),(11, 1)] post #(nil,last0) -> ([(1, 1),(1, 1)], [((5, 1), (1, 1)),((11, 1), (1, 1))]) loc(((5, 1), (1, 1))) [hiv=5, hipwr=1, lov=1, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (1+5*1,1*1) loc(((11, 1), (1, 1))) [hiv=11, hipwr=1, lov=1, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (1+11*1,1*1) post (id_, !loc) -> ([(1, 1),(1, 1)], [(6, 1),(12, 1)]) combine c_lr -> [(1, 1),(1, 1),(6, 1),(12, 1)] post #(nil,last0) -> ([(2, 1),(9, 1),(13, 1),(16, 1)], [((1, 1), (16, 1)),((1, 1), (16, 1)),((6, 1), (16, 1)),((12, 1), (16, 1))]) loc(((1, 1), (16, 1))) [hiv=1, hipwr=1, lov=16, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (16+1*1,1*1) loc(((1, 1), (16, 1))) [hiv=1, hipwr=1, lov=16, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (16+1*1,1*1) loc(((6, 1), (16, 1))) [hiv=6, hipwr=1, lov=16, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (16+6*1,1*1) loc(((12, 1), (16, 1))) [hiv=12, hipwr=1, lov=16, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (16+12*1,1*1) post (id_, !loc) -> ([(2, 1),(9, 1),(13, 1),(16, 1)], [(17, 1),(17, 1),(22, 1),(28, 1)]) combine c_lr -> [(2, 1),(9, 1),(13, 1),(16, 1),(17, 1),(17, 1),(22, 1),(28, 1)] _unzip.0 -> [2,9,13,16,17,17,22,28] -- result: [2,9,13,16,17,17,22,28] --
Your thoughts?
(will not be shared or abused)
Comment:
                                        Feedback is welcome.
Copyright © 2025 Thomas C. Veatch. All rights reserved.
Created: May 2026