Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 0 additions & 89 deletions arithmetic/src/division/srt/SRTTable.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package division.srt

import com.cibo.evilplot.colors.HTMLNamedColors
import com.cibo.evilplot.numeric.Bounds
import com.cibo.evilplot.plot._
import com.cibo.evilplot.plot.aesthetics.DefaultTheme._
import com.cibo.evilplot.plot.renderers.PointRenderer
import os.Path
import spire.implicits._
import spire.math._
Expand All @@ -31,34 +26,6 @@ case class SRTTable(
lazy val xMin: Algebraic = -rho * dMax * radix
lazy val xMax: Algebraic = rho * dMax * radix

/** P-D Diagram
*
* @note Graph 5.17(b)
*/
lazy val pd: Plot = Overlay((aMin.toBigInt to aMax.toBigInt).flatMap { k: BigInt =>
Seq(
FunctionPlot.series(
_ * uRate(k.toInt).toDouble,
s"U($k)",
HTMLNamedColors.blue,
Some(Bounds(dMin.toDouble, dMax.toDouble)),
strokeWidth = Some(1)
),
FunctionPlot.series(
_ * lRate(k.toInt).toDouble,
s"L($k)",
HTMLNamedColors.red,
Some(Bounds(dMin.toDouble, dMax.toDouble)),
strokeWidth = Some(1)
)
) ++ qdsPoints :+ mesh
}: _*)
.title(s"P-D Graph of $this")
.xLabel("d")
.yLabel(s"${radix.toInt}ω[j]")
.rightLegend()
.standard()

lazy val aMax: Algebraic = a
lazy val aMin: Algebraic = -a
lazy val deltaD: Algebraic = pow(2, -dTruncateWidth.toDouble)
Expand All @@ -78,18 +45,6 @@ case class SRTTable(
}
}
}
lazy val qdsPoints: Seq[Plot] = {
tables.map {
case (i, ps) =>
ScatterPlot(
ps.flatMap { case (d, xs) => xs.map(x => com.cibo.evilplot.numeric.Point(d.toDouble, x.toDouble)) },
Some(
PointRenderer
.default[com.cibo.evilplot.numeric.Point](pointSize = Some(1), color = Some(HTMLNamedColors.gold))
)
)
}
}

// TODO: select a Constant from each m, then offer the table to QDS.
// todo: ? select rule: symmetry and draw a line parallel to the X-axis, how define the rule
Expand Down Expand Up @@ -119,53 +74,9 @@ case class SRTTable(
assert((rho > 1 / 2) && (rho <= 1))
private val dSet = Seq.tabulate((dStep + 1).toInt) { n => dMin + deltaD * n }

private val mesh =
ScatterPlot(
xSet.flatMap { y =>
dSet.map { x =>
com.cibo.evilplot.numeric.Point(x.toDouble, y.toDouble)
}
},
Some(
PointRenderer
.default[com.cibo.evilplot.numeric.Point](pointSize = Some(0.5), color = Some(HTMLNamedColors.gray))
)
)

override def toString: String =
s"SRT${radix.toInt} with quotient set: from ${aMin.toInt} to ${aMax.toInt}"

/** Robertson Diagram
*
* @note Graph 5.17(a)
*/
def robertson(d: Algebraic): Plot = {
require(d > dMin && d < dMax)
Overlay((aMin.toBigInt to aMax.toBigInt).map { k: BigInt =>
FunctionPlot.series(
_ - (Algebraic(k) * d).toDouble,
s"$k",
HTMLNamedColors.black,
xbounds = Some(Bounds(((Algebraic(k) - rho) * d).toDouble, ((Algebraic(k) + rho) * d).toDouble))
)
}: _*)
.title(s"Robertson Graph of $this divisor: $d")
.xLabel("rω[j]")
.yLabel("ω[j+1]")
.xbounds((-radix * rho * dMax).toDouble, (radix * rho * dMax).toDouble)
.ybounds((-rho * d).toDouble, (rho * d).toDouble)
.rightLegend()
.standard()
}

def dumpGraph(plot: Plot, path: Path) = {
javax.imageio.ImageIO.write(
plot.render().asBufferedImage,
"png",
path.wrapped.toFile
)
}

// select four points, then drop the first and the last one.
/** for range `dLeft` to `dRight`, return the `rOmegaCeil` and `rOmegaFloor`
* this is used for constructing the rectangle where m_k(i) is located.
Expand Down
3 changes: 0 additions & 3 deletions build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import os._
object v {
val scala = "2.13.15"
val spire = ivy"org.typelevel::spire:0.18.0"
val evilplot = ivy"io.github.cibotech::evilplot:0.9.0"
val oslib = ivy"com.lihaoyi::os-lib:0.9.1"
val mainargs = ivy"com.lihaoyi::mainargs:0.5.0"
val chiselCrossVersions = Map(
Expand Down Expand Up @@ -40,8 +39,6 @@ trait Arithmetic

def spireIvy = v.spire

def evilplotIvy = v.evilplot

def chiselModule = None

def chiselPluginJar = None
Expand Down
4 changes: 1 addition & 3 deletions common.mill
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,5 @@ trait ArithmeticModule
with HasChisel {
def spireIvy: T[Dep]

def evilplotIvy: T[Dep]

override def ivyDeps = T(super.ivyDeps() ++ Seq(spireIvy(), evilplotIvy()))
override def ivyDeps = T(super.ivyDeps() ++ Seq(spireIvy()))
}
2 changes: 1 addition & 1 deletion nix/arithmetic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let
name = "arithmetic";
src = arithmeticSrc;
buildInputs = [ chisel.setupHook ];
millDepsHash = "sha256-NYB4g7uCaQZH7MqA7fdQzB2vXUdXfo37MC6hAMaMIZU=";
millDepsHash = "sha256-lv1d+NSXsV42Xb1NuVZjlz07T6W4Xqkx/3MQvaVqRTA=";
};
in
publishMillJar {
Expand Down