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([5,6,3,7,1,2,0,4], [1,1,1,1,1,1,1,1]) -- _zip -> [(5, 1),(6, 1),(3, 1),(7, 1),(1, 1),(2, 1),(0, 1),(4, 1)] poly_dc([(5, 1),(6, 1),(3, 1),(7, 1),(1, 1),(2, 1),(0, 1),(4, 1)]) divide d_lr -> ([(5, 1),(6, 1),(3, 1),(7, 1)], [(1, 1),(2, 1),(0, 1),(4, 1)]) poly_dc([(5, 1),(6, 1),(3, 1),(7, 1)]) divide d_lr -> ([(5, 1),(6, 1)], [(3, 1),(7, 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)] poly_dc([(3, 1),(7, 1)]) divide d_lr -> ([(3, 1)], [(7, 1)]) poly_dc([(3, 1)]) ⇣ atom; basef -> [(3, 1)] poly_dc([(7, 1)]) ⇣ atom; basef -> [(7, 1)] post #(nil,last0) -> ([(3, 1)], [((7, 1), (3, 1))]) loc(((7, 1), (3, 1))) [hiv=7, hipwr=1, lov=3, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (3+7*1,1*1) post (id_, !loc) -> ([(3, 1)], [(10, 1)]) combine c_lr -> [(3, 1),(10, 1)] post #(nil,last0) -> ([(5, 1),(11, 1)], [((3, 1), (11, 1)),((10, 1), (11, 1))]) loc(((3, 1), (11, 1))) [hiv=3, hipwr=1, lov=11, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (11+3*1,1*1) loc(((10, 1), (11, 1))) [hiv=10, hipwr=1, lov=11, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (11+10*1,1*1) post (id_, !loc) -> ([(5, 1),(11, 1)], [(14, 1),(21, 1)]) combine c_lr -> [(5, 1),(11, 1),(14, 1),(21, 1)] poly_dc([(1, 1),(2, 1),(0, 1),(4, 1)]) divide d_lr -> ([(1, 1),(2, 1)], [(0, 1),(4, 1)]) poly_dc([(1, 1),(2, 1)]) divide d_lr -> ([(1, 1)], [(2, 1)]) poly_dc([(1, 1)]) ⇣ atom; basef -> [(1, 1)] poly_dc([(2, 1)]) ⇣ atom; basef -> [(2, 1)] post #(nil,last0) -> ([(1, 1)], [((2, 1), (1, 1))]) loc(((2, 1), (1, 1))) [hiv=2, hipwr=1, lov=1, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (1+2*1,1*1) post (id_, !loc) -> ([(1, 1)], [(3, 1)]) combine c_lr -> [(1, 1),(3, 1)] poly_dc([(0, 1),(4, 1)]) divide d_lr -> ([(0, 1)], [(4, 1)]) poly_dc([(0, 1)]) ⇣ atom; basef -> [(0, 1)] poly_dc([(4, 1)]) ⇣ atom; basef -> [(4, 1)] post #(nil,last0) -> ([(0, 1)], [((4, 1), (0, 1))]) loc(((4, 1), (0, 1))) [hiv=4, hipwr=1, lov=0, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (0+4*1,1*1) post (id_, !loc) -> ([(0, 1)], [(4, 1)]) combine c_lr -> [(0, 1),(4, 1)] post #(nil,last0) -> ([(1, 1),(3, 1)], [((0, 1), (3, 1)),((4, 1), (3, 1))]) loc(((0, 1), (3, 1))) [hiv=0, hipwr=1, lov=3, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (3+0*1,1*1) loc(((4, 1), (3, 1))) [hiv=4, hipwr=1, lov=3, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (3+4*1,1*1) post (id_, !loc) -> ([(1, 1),(3, 1)], [(3, 1),(7, 1)]) combine c_lr -> [(1, 1),(3, 1),(3, 1),(7, 1)] post #(nil,last0) -> ([(5, 1),(11, 1),(14, 1),(21, 1)], [((1, 1), (21, 1)),((3, 1), (21, 1)),((3, 1), (21, 1)),((7, 1), (21, 1))]) loc(((1, 1), (21, 1))) [hiv=1, hipwr=1, lov=21, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (21+1*1,1*1) loc(((3, 1), (21, 1))) [hiv=3, hipwr=1, lov=21, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (21+3*1,1*1) loc(((3, 1), (21, 1))) [hiv=3, hipwr=1, lov=21, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (21+3*1,1*1) loc(((7, 1), (21, 1))) [hiv=7, hipwr=1, lov=21, lopwr=1] -> (lov+hiv*lopwr,lopwr*hipwr) = (21+7*1,1*1) post (id_, !loc) -> ([(5, 1),(11, 1),(14, 1),(21, 1)], [(22, 1),(24, 1),(24, 1),(28, 1)]) combine c_lr -> [(5, 1),(11, 1),(14, 1),(21, 1),(22, 1),(24, 1),(24, 1),(28, 1)] _unzip.0 -> [5,11,14,21,22,24,24,28] -- result: [5,11,14,21,22,24,24,28] --
Your thoughts?
(will not be shared or abused)
Comment:
                                        Feedback is welcome.
Copyright © 2025 Thomas C. Veatch. All rights reserved.
Created: May 2026