Class RecursiveSequence<T>

java.lang.Object
org.episteme.core.mathematics.analysis.series.RecursiveSequence<T>
All Implemented Interfaces:
Function<Natural,T>, Function<Natural,T>, Relation<Natural,T>, Sequence<T>

public abstract class RecursiveSequence<T> extends Object implements Sequence<T>
Represents a sequence defined by a recurrence relation.

Supports memoization to efficiently calculate terms.

Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Constructor Details

    • RecursiveSequence

      public RecursiveSequence()
  • Method Details

    • calculate

      protected abstract T calculate(int n)
      Calculates the n-th term using the recurrence relation. Implementations should call get(int) for previous terms to utilize caching.
      Parameters:
      n - the index
      Returns:
      the n-th term
    • get

      public T get(int n)
      Description copied from interface: Sequence
      Convenience method for primitive int indices.

      Delegates to Sequence.get(Natural) after converting to Natural.

      Specified by:
      get in interface Sequence<T>
      Parameters:
      n - the index (must be ≥ 0)
      Returns:
      a(n)
    • clearCache

      public void clearCache()
      Clears the memoization cache.