Package elki.math

Class SinCosTable

  • Direct Known Subclasses:
    SinCosTable.FullTable, SinCosTable.HalfTable, SinCosTable.QuarterTable

    public abstract class SinCosTable
    extends java.lang.Object
    Class to precompute / cache Sinus and Cosinus values. Note that the functions use integer offsets, not radians. TODO: add an interpolation function. TODO: add caching
    Since:
    0.5.5
    Author:
    Erich Schubert
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  SinCosTable.FullTable
      Table that can't exploit much symmetry, because the steps are not divisible by 2.
      private static class  SinCosTable.HalfTable
      Table that exploits just one symmetry, as the number of steps is divisible by two.
      private static class  SinCosTable.QuarterTable
      Table that exploits both symmetries, as the number of steps is divisible by four.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int steps
      Number of steps.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private SinCosTable​(int steps)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract double cos​(int step)
      Get Cosine by step value.
      static SinCosTable make​(int steps)
      Make a table for the given number of steps.
      abstract double sin​(int step)
      Get Sinus by step value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • steps

        protected final int steps
        Number of steps.
    • Constructor Detail

      • SinCosTable

        private SinCosTable​(int steps)
        Constructor.
        Parameters:
        steps - Number of steps (ideally, steps % 4 = 0!)
    • Method Detail

      • cos

        public abstract double cos​(int step)
        Get Cosine by step value.
        Parameters:
        step - Step value
        Returns:
        Cosinus
      • sin

        public abstract double sin​(int step)
        Get Sinus by step value.
        Parameters:
        step - Step value
        Returns:
        Sinus
      • make

        public static SinCosTable make​(int steps)
        Make a table for the given number of steps. For step numbers divisible by 4, an optimized implementation will be used.
        Parameters:
        steps - Number of steps
        Returns:
        Table