Post Reply 
(49G) Shortest Integer Linear Combination of Two Vectors
07-26-2015, 10:34 AM (This post was last modified: 06-15-2017 01:42 PM by Gene.)
Post: #1
(49G) Shortest Integer Linear Combination of Two Vectors
For input of two conformable vectors the programme returns a shortest integer linear combination.(A small problem of English - the indefinite article in the previous sentence seems awkward.)

eg For input

[ 6 26 38 146 ]

[ 35 49 77 462 ]

the programme returns

[ 17 -29 -37 24 ]

Code:

::
  CK2&Dispatch
  BINT68
  ::
    FPTR2 ^CKSAMESIZE
    NcaseSIZEERR
    FPTR2 ^PUSHFLAGS_
    "   Min Non-Zero Z-Linear Comb"
    DispCoord1
    SetDA3Temp
    FPTR2 ^SETEXACT
    FPTR2 ^QpiArry
    SWAP
    FPTR2 ^QpiArry
    OVERDUP
    FPTR2 ^XYext
    OVERDUP
    FPTR2 ^XYext
    2DUP
    Z<
    IT
    ::
      SWAP4ROLL
      3UNROLL
    ;
    BEGIN
    4PICK
    4PICK
    FPTR2 ^XYext
    2DUPSWAP
    FPTR2 ^QDiv
    Z1_
    Z2_
    FPTR2 ^NDXFext
    FPTR2 ^QAdd
    FPTR2 ^FXNDext
    FPTR2 ^ZQUOText
    4PICKOVER
    4ROLL
    FPTR2 ^QMul
    DUP
    FPTR2 ^QAdd
    FPTR2 ^QSub
    OVER
    FPTR2 ^ZSQ_
    4PICK
    FPTR2 ^QMul
    FPTR2 ^QAdd
    DUP
    4PICK
    Z>=
    ITE
    TRUE
    ::
      6ROLL
      ROT
      6PICK
      FPTR2 ^SCL*MAT
      FPTR2 ^MAT-
      4UNROLLROT
      DROPFALSE
    ;
    UNTIL
    6ROLL
    5DROP
    FPTR2 ^POPFLAGS_
  ;
;
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: