R Under development (unstable) (2023-04-23 r84305 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > library(rcdd) If you want correct answers, use rational arithmetic. See the Warnings sections in help pages for functions that do computational geometry. > > foo <- z2q(c(1:5), c(6:10)) > > bar <- z2q(c(0:4), c(11:15)) > > print(foo) [1] "1/6" "2/7" "3/8" "4/9" "1/2" > > print(bar) [1] "0" "1/12" "2/13" "3/14" "4/15" > > ##### addition ##### > > .Call(rcdd:::C_qoq, foo, bar, as.integer(1)) [1] "1/6" "31/84" "55/104" "83/126" "23/30" > > qpq(foo, bar) [1] "1/6" "31/84" "55/104" "83/126" "23/30" > > ##### subtraction ##### > > .Call(rcdd:::C_qoq, foo, bar, as.integer(2)) [1] "1/6" "17/84" "23/104" "29/126" "7/30" > > qmq(foo, bar) [1] "1/6" "17/84" "23/104" "29/126" "7/30" > > ##### multiplication ##### > > .Call(rcdd:::C_qoq, foo, bar, as.integer(3)) [1] "0" "1/42" "3/52" "2/21" "2/15" > > qxq(foo, bar) [1] "0" "1/42" "3/52" "2/21" "2/15" > > ##### division ##### > > .Call(rcdd:::C_qoq, bar, foo, as.integer(4)) [1] "0" "7/24" "16/39" "27/56" "8/15" > > qdq(bar, foo) [1] "0" "7/24" "16/39" "27/56" "8/15" > > options(error=dump.frames) > > .Call(rcdd:::C_qoq, foo, bar, as.integer(4)) Error: rational divide by zero > > qdq(foo, bar) Error in qdq(foo, bar) : rational divide by zero > > > proc.time() user system elapsed 0.21 0.09 0.28