Copyright | (c) Esa Pulkkinen 2018 |
---|---|
License | LGPL |
Maintainer | esa.pulkkinen@iki.fi |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
Math.Number.Stream
Contents
Description
This module implements lazy infinite streams, stream generating functions and lots of operations on the lazy streams. some examples for use of this module:
fib = 1 `div` (1 - s_z - s_z*s_z)
pascalTriangle = Matrix $ 1 `div` (1 - s_z - s_z2*s_z)
take 4 fib == [1,1,2,3]
alternating_bits = cycle [0,1]
Synopsis
- (!) :: Stream a -> Integer -> a
- type RealClosure str a = (Ord a, Num a, Limiting str a, Real (Closure str a))
- type RealClosure2 str a = (RealClosure str a, Limiting (str :*: str) a, Real (Closure (str :*: str) a))
- stailStream :: Stream a -> Stream a
- sheadStrict :: Stream a -> a
- matrixPowers :: (SupportsMatrixMultiplication g g g a, Diagonalizable g a, LinearTransform g g a) => (g :*: g) a -> Stream ((g :*: g) a)
- powerSeriesPowers :: Num a => Stream a -> (Stream :*: Stream) a
- compose_powerSeries :: (Closed a, Num a) => Stream a -> Stream a -> Stream a
- compositions :: Stream (a -> a) -> Stream (a -> a)
- powerSeries_exp :: (Fractional a, Closed a) => Stream a -> Stream a
- matrixExponentialStream :: (Fractional (Scalar ((g :*: g) a)), Diagonalizable g a, LinearTransform g g a, SupportsMatrixMultiplication g g g a, InnerProductSpace (g a), VectorSpace ((g :*: g) a), Num ((g :*: g) a), Scalar (g (g a)) ~ Scalar (g a), Scalar (g a) ~ a, Scalar a ~ a) => (g :*: g) a -> Stream ((g :*: g) a)
- matrixExponential :: (Fractional (Scalar ((g :*: g) a)), SupportsMatrixMultiplication g g g a, Diagonalizable g a, LinearTransform g g a, InnerProductSpace (g a), VectorSpace ((g :*: g) a), Num ((g :*: g) a), Scalar (g (g a)) ~ Scalar (g a), Scalar (g a) ~ a, Scalar a ~ a) => (g :*: g) a -> (g :*: g) a
- constantIntegerClosure :: Integer -> Closure Stream Integer
- infiniteInteger :: Closure Stream Integer
- negativeInfiniteInteger :: Closure Stream Integer
- limiting_iso :: (BiArrow arr, Limiting Stream a) => arr (Stream a) (Closure Stream a)
- vecStream :: Stream a -> Integer -> a
- cmap :: (Limiting s a, Limiting s b) => (a -> b) -> Closure s a -> Closure s b
- cliftA2 :: (Limiting s a, Limiting s b, Limiting s c) => (a -> b -> c) -> Closure s a -> Closure s b -> Closure s c
- close :: Limiting Stream a => a -> Closure Stream a
- closure_limit :: (Num a, Closed a, Limiting Stream a) => Stream (Closure Stream a) -> Closure Stream a
- (.>>=.) :: (Limiting s a, Limiting s b) => Closure s a -> (a -> Closure s b) -> Closure s b
- eigenvector_by_power_iteration :: (Fractional (Scalar (m a)), NormedSpace (m a), LinearTransform m m a) => (m :*: m) a -> m a -> Stream (m a)
- stream_distance_count :: Eq a => Stream a -> Stream a -> Integer
- stream_distance :: Eq a => Stream a -> Stream a -> Rational
- taylor :: (Fractional a, DifferentiallyClosed a) => (a -> a) -> a -> (Stream :*: Stream) a
- stream_identityMatrix :: (Integral a, RealClosure2 Stream a) => (Stream :*: Stream) a
- streamDiagonal :: Linearizable LinearMap (:*:) Stream Stream a => (Stream a :-> Stream a) -> Stream a
- ssum :: (Closed a, Num a) => Stream a -> a
- svsum :: (Closed a, VectorSpace a) => Stream a -> a
- increasing_substream :: Ord a => Stream a -> Stream a
- sub_member :: Ord a => Stream a -> a -> Bool
- bindMatrix :: (ConjugateSymmetric a, Num a, Closed a) => (Stream a :-> Stream a) -> (a -> Stream a -> Stream a -> Stream b) -> Stream b
- streamAs_diagonal :: (ConjugateSymmetric a, Num a, Closed a) => Stream a -> Stream a :-> Stream a
- add_row :: f a -> (Stream :*: f) a -> (Stream :*: f) a
- first_row :: (Stream :*: g) a -> g a
- first_column :: Functor f => (f :*: Stream) a -> f a
- remove_row :: (Stream :*: f) a -> (Stream :*: f) a
- remove_row_endo :: Endo ((Stream :*: f) a)
- add_column :: Applicative f => f a -> (f :*: Stream) a -> (f :*: Stream) a
- add_column_endo :: Applicative f => f a -> Endo ((f :*: Stream) a)
- remove_column :: Functor f => (f :*: Stream) a -> (f :*: Stream) a
- remove_column_endo :: Functor f => Endo ((f :*: Stream) a)
- join3 :: (ConjugateSymmetric a, Num a, Closed a) => (Stream a :-> Stream a) -> Stream (a, a, a)
- tails :: Stream a -> (Stream :*: Stream) a
- skippers :: Stream a -> (Stream :*: Stream) a
- fromComplex :: RealFloat a => Complex a -> Stream (Complex a)
- adjusted_sequence_product :: Fractional a => Stream a -> Stream a -> Stream a
- average_seq :: Fractional a => Seq a -> a
- convolution_productMatrix :: (Functor m, Functor n, Num a) => (m :*: Stream) a -> (n :*: Stream) a -> (m :*: n) (Stream a)
- sum_seq :: Num a => Seq a -> a
- streamPowers :: Num a => Stream a -> (Stream :*: Stream) a
- compose :: (ConjugateSymmetric a, Num a, Eq a) => Stream a -> Stream a -> Stream a
- matrixConvolution :: (SupportsMatrixMultiplication f g h a, VectorSpace ((f :*: h) a)) => Stream ((f :*: g) a) -> Stream ((g :*: h) a) -> Stream ((f :*: h) a)
- matrixConvolutionLinear :: (SupportsMatrixMultiplication f g h a, Linearizable LinearMap (:*:) g h a, Linearizable LinearMap (:*:) f g a, Linearizable LinearMap (:*:) f h a, VectorSpace ((f :*: h) a)) => Stream (f a :-> g a) -> Stream (g a :-> h a) -> Stream (f a :-> h a)
- matrixConvolutionProductLinear :: (Closed a, Fractional a, ConjugateSymmetric a) => (Stream a :-> Stream a) -> (Stream a :-> Stream a) -> Stream a :-> Stream a
- matrixConvolutionProduct :: (ConjugateSymmetric a, Fractional a) => (Stream :*: Stream) a -> (Stream :*: Stream) a -> (Stream :*: Stream) a
- distanceProduct :: (Floating a, ConjugateSymmetric a) => Stream a -> Stream a -> Stream a
- nonzeroPermutation :: (Num a, Eq a) => Stream a -> (Stream a, Stream Integer)
- prefixMatrix :: a -> Stream a -> Stream a -> (Stream :*: Stream) a -> (Stream :*: Stream) a
- composePermutation :: Stream Integer -> Stream Integer -> Stream Integer
- permutationMatrix_from_indices :: Num a => Stream Integer -> (Stream :*: Stream) a
- luDecompositionStreamMatrix :: (Floating a, Eq a) => (Stream :*: Stream) a -> ((Stream :*: Stream) a, (Stream :*: Stream) a, Stream Integer)
- min_convolution :: (Num a, Ord a) => Stream a -> Stream a -> Stream a
- andStream :: Stream Bool -> Stream Bool -> Stream Bool
- orStream :: Stream Bool -> Stream Bool -> Stream Bool
- fromNum :: Num a => a -> Stream a
- cycleQueueBy :: (a -> b -> b) -> Queue a -> b
- cycleQueue :: Queue a -> Stream a
- convolveWith :: Num a => ([a] -> b) -> (c -> d -> a) -> Stream c -> Stream d -> Stream b
- convolveWithSeq :: Num a => (Seq a -> b) -> (c -> d -> a) -> Stream c -> Stream d -> Stream b
- data StreamIndex a = StreamIndex {
- sindexPosition :: Integer
- sindexElement :: a
- streamfold :: (a -> b -> b) -> Fold (Stream a) b
- foldCodiagonals :: Num a => ([a] -> b -> b) -> (Stream :*: Stream) a -> b
- streamfold2 :: (a -> c -> b) -> (a -> b -> c) -> Fold (Stream a) b
- streamfoldLst :: [a -> b -> b] -> Fold (Stream a) b
- streamfoldStream :: Stream (a -> b -> b) -> Fold (Stream a) b
- rotatePrefix :: Integer -> Stream a -> Stream a
- threeNplusOne :: Integer -> Integer
- collatz :: Integer -> [Integer]
- toNatSeq :: Stream a -> Rec Maybe -> a
- fromIntegerSeq :: (Integer -> a) -> Stream a
- sumSeq :: (Num b, Num a, Ord a) => (a -> b) -> a -> Stream b
- boolValue :: Num a => Bool -> a
- fromBoolSeq :: Num a => (Integer -> Bool) -> Stream a
- streamIndexFold :: Fold (Stream a) (Integer -> a)
- streamindex :: Integer -> Stream a -> a
- streamindex2 :: (Integer, Integer) -> (Stream :*: Stream) a -> a
- mapIndices :: (Integer -> Integer) -> Stream a -> Stream a
- limitFold :: (a -> a -> a) -> Fold (Stream a) (Integer -> a)
- limitFoldGen :: (a -> b -> b) -> (a -> b) -> Fold (Stream a) (Integer -> b)
- streamDifferences :: Num a => Stream a -> Stream a
- streamQuotients :: Fractional a => Stream a -> Stream a
- fixpoint :: Limiting str a => (a -> a) -> a -> Closure str a
- matrix_inverse :: (ConjugateSymmetric (g2 a), LinearTransform (f2 :*: g1) (f2 :*: g1) (g2 a), FunctorArrow (f2 :*: g1) LinearMap LinearMap, InnerProductSpaceFunctor g1 (g2 a), InnerProductSpaceFunctor f2 (g2 a), Transposable f2 g1 (g2 a), Transposable g1 f2 (g2 a), Linearizable LinearMap (:*:) g1 f2 (g2 a), Linearizable LinearMap (:*:) f2 g1 (g2 a), Linearizable LinearMap (:*:) f2 g1 (g2 a), Num a, VectorSpace ((:*:) f2 g1 (g2 a)), Scalar (f2 (g2 a)) ~ g2 a, Scalar (g1 (g2 a)) ~ g2 a, Linearizable LinearMap (:*:) g2 g2 a, VectorSpace ((:*:) g2 g2 a), Diagonalizable g2 a) => (g1 (g2 a) :-> f2 (g2 a)) -> (f2 (g2 a) :-> g1 (g2 a)) -> Stream (f2 (g2 a) :-> g1 (g2 a))
- streamMin :: Ord a => Fold (Stream a) (Integer -> a)
- streamMax :: Ord a => Fold (Stream a) (Integer -> a)
- liftStream2 :: (a -> a -> a) -> Stream a -> Stream a
- minStream :: Ord a => Stream a -> Stream a
- maxStream :: Ord a => Stream a -> Stream a
- streamProduct :: Num a => Fold (Stream a) (Integer -> a)
- streamSum :: Num a => Fold (Stream a) (Integer -> a)
- productStream :: Num a => Stream a -> Stream a
- sumStream :: Num a => Stream a -> Stream a
- vsumStream :: VectorSpace a => Stream a -> Stream a
- sumStreamIntegral :: (RealClosure Stream a, Integral a) => Stream a -> Stream a
- sumStreamFractional :: Fractional a => Stream a -> Stream a
- cobind :: (ConjugateSymmetric a, Num a, Closed a) => (a -> b) -> (Stream a :-> Stream a) -> Stream b
- indexedLookup :: Stream Integer -> Stream a -> Stream a
- topleft :: (ConjugateSymmetric a, Num a, Closed a) => (Stream a :-> Stream a) -> a
- streamCodiagonal :: Linearizable LinearMap (:*:) Stream Stream a => (Stream a :-> Stream a) -> Stream (Stream a, Stream a)
- zeroCodiagonal :: a -> Codiagonal Stream a
- streamDiagonalMatrix :: Stream a -> (Stream :*: Stream) a -> (Stream :*: Stream) a
- streamMatrix :: Linearizable LinearMap (:*:) Stream Stream a => Stream a -> Stream (Stream a, Stream a) -> Stream a :-> Stream a
- from_triangular_matrices :: Stream a -> (Stream :*: Stream) a -> (Stream :*: Stream) a -> (Stream :*: Stream) a
- triangularMatrix_iso :: (Stream :*: Stream) a :==: ((Stream :*: Stream) a, Stream a, (Stream :*: Stream) a)
- first_row_iso :: (Stream :*: Stream) a :==: (Stream a, (Stream :*: Stream) a)
- first_col_iso :: (Stream :*: Stream) a :==: (Stream a, (Stream :*: Stream) a)
- triangularOrderMatrix :: Num a => (Stream :*: Stream) a
- prefixStreamMatrix :: (ConjugateSymmetric a, Num a, Closed a) => a -> (Stream a, Stream a) -> (Stream a :-> Stream a) -> Stream a :-> Stream a
- pseudoCodiagonal :: (Stream :*: Stream) a -> Codiagonal Stream a
- pseudoMatrix :: Stream a -> Stream (Stream a, Stream a) -> (Stream :*: Stream) a
- mapMatrix :: (Num a, Num b) => (a -> b) -> ((Stream a, Stream a) -> (Stream b, Stream b)) -> (Stream :*: Stream) a -> (Stream :*: Stream) b
- mapDiagonal :: Num a => (a -> a) -> (Stream :*: Stream) a -> (Stream :*: Stream) a
- joinWith :: (a -> b -> c) -> Stream a -> Stream b -> Stream c
- sheadIndex :: Index Stream a
- stailIndex :: Index Stream a -> Index Stream a
- zipList :: ([a] -> b) -> [Stream a] -> Stream b
- sequence :: [Stream a] -> Stream [a]
- unzipList :: Stream [a] -> [Stream a]
- zipStream :: Functor f => (f b -> a) -> f (Stream b) -> Stream a
- sequenceStream :: Functor f => f (Stream a) -> Stream (f a)
- apply3 :: Stream (a -> b -> c) -> Stream a -> Stream b -> Stream c
- applyA :: Arrow arr => Stream (arr a b) -> arr (Stream a) (Stream b)
- dematrix :: (ConjugateSymmetric a, Num a, Closed a) => (Stream a :-> Stream a) -> (a, (Stream a, Stream a), Stream a :-> Stream a)
- dematrixImpl :: (Stream :*: Stream) a -> (a, (Stream a, Stream a), (Stream :*: Stream) a)
- codiagonals_linear :: (ConjugateSymmetric a, Num a, Closed a) => (Stream a :-> Stream a) -> Stream [a]
- codiagonals_list :: Num a => (Stream :*: Stream) a -> Stream [a]
- codiagonalsSeq :: (Stream :*: Stream) a -> Stream (Seq a)
- codiagonals :: (Stream :*: Stream) a -> Stream [a]
- uncodiagonals :: Linearizable LinearMap (:*:) Stream Stream a => Stream [a] -> Stream a :-> Stream a
- uncodiagonalsImpl :: Stream [a] -> (Stream :*: Stream) a
- takes :: Stream Integer -> Stream a -> Stream [a]
- split_dimension :: (ConjugateSymmetric a, Num a, Closed a) => Stream a -> Stream a :-> Stream a
- split_planar :: (ConjugateSymmetric a, Num a, Closed a) => Stream a -> Stream a :-> Stream a
- codiagonalsIso :: (ConjugateSymmetric a, Num a, Closed a, BiArrow arr) => arr (Stream a :-> Stream a) (Stream [a])
- lowerTriangle :: Linearizable LinearMap (:*:) Stream Stream a => (Stream a :-> Stream a) -> Stream a :-> Stream a
- lowerTriangleImpl :: (Stream :*: Stream) a -> (Stream :*: Stream) a
- upperTriangle :: Linearizable LinearMap (:*:) Stream Stream a => (Stream a :-> Stream a) -> Stream a :-> Stream a
- upperTriangleImpl :: (Stream :*: Stream) a -> (Stream :*: Stream) a
- pairingMatrix :: Fractional a => (Stream :*: Stream) a
- concatenate :: Stream [a] -> Stream a
- diagonalize :: Stream [a] -> Stream a
- skipEven :: Stream a -> Stream a
- niceTail :: [a] -> [a]
- diagonalDifferences :: (ConjugateSymmetric a, Num a, Closed a) => (a -> b) -> (Stream a :-> Stream a) -> Stream b
- findEqual :: Eq a => Stream a -> Stream a -> a
- fixedpoint :: (ConjugateSymmetric a, Num a, Closed a, Eq a) => (a -> a) -> (Stream a :-> Stream a) -> a
- sumJoin :: Num a => (Stream :*: Stream) a -> Stream a
- sumBind :: Num b => Stream a -> (a -> Stream b) -> Stream b
- cojoin :: (Stream :*: Stream) a -> Stream a
- (|*|) :: Closed a => Stream a -> Stream a -> Stream (Vector2 a)
- (>>!=) :: Num b => Stream a -> (a -> Stream b) -> Stream b
- (>!=) :: Num b => Stream a -> (a -> Stream b) -> Stream [b]
- integers :: Num a => Stream a
- integersStream :: Stream Integer
- naturals :: Num a => Stream a
- naturals_starting_from :: (Num a, Ord a) => a -> Stream a
- nonzeroNaturals :: Num a => Stream a
- integral_nonzeroNaturals :: (Num a, Integral (Stream a)) => Stream a
- integral_naturals :: (Num a, Integral (Stream a)) => Stream a
- s_z :: Num a => Stream a
- s_z2 :: Num a => Stream (Stream a)
- z2Matrix :: Num a => (Stream :*: Stream) a
- s_z3 :: Num a => Stream (Stream (Stream a))
- s_z4 :: Num a => Stream (Stream (Stream (Stream a)))
- z3Matrix :: Num a => ((Stream :*: Stream) :*: Stream) a
- logStream :: Num a => (Stream :*: Stream) a
- streamLogarithm :: Fractional a => Stream a -> Stream a
- streamLog :: Integral a => Stream a -> Stream a
- approximateSums :: Fractional a => Stream a -> Stream a -> Stream a
- exponentialStream :: Fractional a => Stream a
- exponential :: (ConjugateSymmetric a, Eq a, Fractional a) => Stream a -> Stream a
- logGeneratingFunction :: Fractional a => Stream a
- cosStream :: (Closed a, Fractional a) => Stream a -> Stream a
- sinStream :: (Closed a, Fractional a) => Stream a -> Stream a
- sinGeneratingFunction :: Fractional a => Stream a
- cosGeneratingFunction :: Fractional a => Stream a
- factorial :: Num a => Stream a
- reciprocal :: Fractional a => Stream a -> Stream a
- inversion :: Integral a => Stream a -> Stream a
- quotientInvert :: Integral a => Stream a -> Stream a
- unitProduct :: Num a => Stream a
- zero :: Num a => Stream a
- streamIf :: Stream Bool -> Stream a -> Stream a -> Stream a
- either :: (a -> c) -> (b -> c) -> Stream (Either a b) -> Stream c
- splitEither :: Stream (Either a b) -> (Stream a, Stream b)
- splitEitherBool :: Stream (Either a b) -> (Stream Bool, Stream a, Stream b)
- joinEither :: Stream Bool -> Stream a -> Stream b -> Stream (Either a b)
- subtract :: Num a => Stream a -> Stream a -> Stream a
- prefix :: [a] -> Stream a -> Stream a
- fromList :: Num a => [a] -> Stream a
- toList :: Stream a -> [a]
- filter :: (a -> Bool) -> Stream a -> Stream a
- remove :: Eq a => [a] -> Stream a -> Stream a
- interleaveCount :: Integer -> Stream a -> Stream a -> Stream a
- uninterleaveIndex :: Integer -> Stream a -> Stream a
- interleaveStream :: Stream a -> Stream a -> Stream a
- interleaveEither :: Stream a -> Stream b -> Stream (Either a b)
- uninterleave :: Stream a -> (Stream a, Stream a)
- interleave3 :: Stream a -> Stream a -> Stream a -> Stream a
- uninterleave3 :: Stream a -> (Stream a, Stream a, Stream a)
- uninterleaveIndices :: Integer -> Integer -> Stream a -> Stream a
- interleaveLst :: [Stream a] -> Stream a
- uninterleaveLst :: Integer -> Stream a -> [Stream a]
- interleaveQueue :: (Queue :*: Stream) a -> Stream a
- uninterleaveQueue :: Integer -> Stream a -> (Queue :*: Stream) a
- square :: Num a => [[a]] -> (Stream :*: Stream) a
- drop :: Integer -> Stream a -> Stream a
- take :: Integer -> Stream a -> [a]
- splitAt :: Integer -> Stream a -> ([a], Stream a)
- take2d :: (Integer, Integer) -> (Stream :*: Stream) a -> (List :*: List) a
- drop2d :: (Integer, Integer) -> (Stream :*: Stream) a -> (Stream :*: Stream) a
- countWhile :: (a -> Bool) -> Stream a -> Integer
- takeWhile :: (a -> Bool) -> Stream a -> [a]
- dropWhile :: (a -> Bool) -> Stream a -> Stream a
- span :: (a -> Bool) -> Stream a -> ([a], Stream a)
- cycle :: [a] -> Stream a
- cycledQueue :: Queue a -> Stream a
- stirlingNumbers :: Num a => (Stream :*: Stream) a
- negativeStirlingNumbers :: Num a => (Stream :*: Stream) a
- naturalPrefixes :: Num a => Stream [a]
- toSquare :: (Stream :*: Stream) a -> [[a]]
- printSquare :: PpShow a => (Stream :*: Stream) a -> Doc
- power :: Fractional a => Integer -> Stream a
- powerUniformFractional :: Fractional a => a -> Stream a
- powerIntegral :: Integral a => Integer -> Stream a
- powerUniformIntegral :: Integral a => a -> Stream a
- indexPowers :: Num a => Stream a -> Stream a
- substitute :: Num a => Stream a -> Stream a -> Stream a
- fourier_ :: RealFloat a => Complex a -> Stream (Complex a) -> Stream (Complex a)
- expGeneratingFunction :: (ConjugateSymmetric a, Closed a, Floating a, Eq a) => Stream a
- exponentialGeneratingFunction :: Fractional a => Stream a -> Stream a
- poissonGeneratingFunction :: (ConjugateSymmetric a, Closed a, Eq a, Floating a) => Stream a -> Stream a
- preSubst :: Num a => Stream a -> Stream a -> Stream [a]
- subst :: (Closed a, Num a) => Stream a -> Stream a -> Stream a
- multiply :: Num a => a -> Stream a -> Stream a
- powers :: Num a => Stream a -> (Stream :*: Stream) a
- cauchyPowers :: Num a => a -> Stream a
- binomialCoefficient :: (Integral a, RealClosure2 Stream a) => Integer -> Integer -> a
- catalanNumbers :: (Integral a, RealClosure Stream a) => Stream a
- catalanNumbersFloating :: (ConjugateSymmetric a, Closed a, Eq a, Floating a) => Stream a
- pascalTriangle :: (Integral a, RealClosure2 Stream a) => (Stream :*: Stream) a
- pascalTriangleDiag :: (Integral a, RealClosure2 Stream a) => (Stream :*: Stream) a
- pascalTriangleDiagFractional :: Fractional a => (Stream :*: Stream) a
- binomialCoefficients :: (Integral a, RealClosure2 Stream a) => Stream [a]
- binomialCoefficientsSeq :: (Integral a, RealClosure2 Stream a) => Stream (Seq a)
- expApprox :: (Fractional a, RealClosure2 Stream a) => a -> Stream a
- polynomialPowers :: (Integral a, RealClosure2 Stream a) => a -> a -> Stream a
- polynomialPowersFractional :: Fractional a => a -> a -> Stream a
- fib :: (Integral a, RealClosure Stream a) => Stream a
- triangularNumbers :: (Integral a, RealClosure Stream a) => Stream a
- squares :: (Num a, Integral (Stream a)) => Stream a
- alternatingSigns :: Fractional a => Stream a
- alternatingBits :: Fractional a => Stream a
- alternatingPossiblyNegativeBits :: Fractional a => Stream a
- oddIntegers :: Integral a => Stream a
- oddIntegers_ :: (Num a, Integral (Stream a)) => Stream a
- integersDivisibleBy :: Integer -> Stream Integer
- positiveResidueClassModulo :: Integer -> Integer -> Stream Integer
- negativeResidueClassModulo :: Integer -> Integer -> Stream Integer
- residueClassModulo :: Integer -> Integer -> Stream Integer
- peircesTriangleFunc :: (Num a, Ord a) => a -> a -> a
- peircesTriangle :: (Num a, Ord a) => (Stream :*: Stream) a
- peircesTriangleList :: (Num a, Ord a) => Stream [a]
- fallingFactorialPowersDiag :: (Real (Closure Stream a), Real (Closure (Stream :*: Stream) a), ConjugateSymmetric a, Integral a, Closed a) => Stream a :-> Stream a
- fallingFactorialPowers :: (Eq a, Num a) => (Stream :*: Stream) a
- risingFactorialPowers :: (Eq a, Num a) => (Stream :*: Stream) a
- bell_numbers :: (Num a, Ord a) => Stream a
- integerPartitionsWithParts :: (Num a, Integral (Stream a)) => Integer -> Stream a
- squareRoot :: Integral a => a -> Stream a
- fractionalSquareRoot :: (Fractional a, Eq a) => a -> Stream a
- detectCycle :: Eq a => Stream a -> [a]
- integerPartitions :: (Num a, Integral (Stream a)) => (Stream :*: Stream) a
- primes :: Integral t => Stream t
- derivative :: Num a => Stream a -> Stream a
- subtractOrdered :: Ord a => Stream a -> Stream a -> Stream a
- joinOrdered :: Ord a => Stream a -> Stream a -> Stream a
- monotonicMembership :: Ord a => Stream a -> Stream a -> Stream Bool
- sqrtStream :: Floating a => Stream a -> Stream a
- cosStreamRealFloat :: (RealFloat a, Infinitesimal Stream a) => Stream a -> Stream a
- sinStreamRealFloat :: (RealFloat a, Infinitesimal Stream a) => Stream a -> Stream a
- streamEpsilon :: (ConjugateSymmetric a, Closed a, Fractional a) => Stream a :-> Stream a
- anotherEpsilon :: (ConjugateSymmetric a, Closed a, Fractional a) => Stream a :-> Stream a
- streamDerivate :: (Fractional a, Closed a, Infinitesimal str (Stream a)) => (Stream a -> Stream a) -> Stream a -> Closure str (Stream a)
- streamIntegral :: (Closed b, Infinitesimal str (Stream b), Fractional b, Enum b) => (Stream b -> Stream b) -> (Stream b, Stream b) -> Closure str (Stream b)
- streamPi :: (Infinitesimal str (Stream a), ConjugateSymmetric a, Closed a, Fractional a, Enum a, Eq a, Floating a) => Closure str (Stream a)
- complexPi :: (Closed a, RealFloat a) => Stream (Complex a)
- twinPrimes :: Integral a => Stream a
- gcd_primes_diff :: Integral a => Stream a
- gcd_primes :: Integral a => Stream a
- gcd_prime_gen :: Integral a => a -> a
- vectorEpsilon :: Infinitesimal Stream a => Stream (Vector3 a)
- derivativeCoefficients :: (Num a, Integral (Stream (Stream a))) => (Stream :*: Stream) a
- derivativeCoefficientsFractional :: Fractional a => (Stream :*: Stream) a
- derivativeLinearMap :: (ConjugateSymmetric a, Closed a) => Stream a :-> Stream a
- bernoulliMinus :: Fractional a => Integer -> a
- bernoulliPlus :: Fractional a => Integer -> a
- bernoulli :: Fractional a => Stream a
- bernoulliPolynomial :: Fractional b => b -> Integer -> b
- bernoulliPolynomials :: Fractional a => (Stream :*: Stream) a
- bernoulliPolynomialCoefficients :: Fractional a => Stream [a]
- legendrePolynomials :: (Eq a, ConjugateSymmetric a, Floating a) => (Stream :*: Stream) a
- legendrePolynomialLists :: (Num a, Eq a, ConjugateSymmetric a, Floating a) => Stream [a]
- evaluatePolynomial :: Fractional a => [a] -> a -> a
- evaluateLegendrePolynomial :: (Fractional a, Eq a, ConjugateSymmetric a, Floating a) => Integer -> a -> a
- evaluateLegendreAt :: (Fractional a, Eq a, ConjugateSymmetric a, Floating a) => a -> Stream a
- circlePeriods :: Floating a => Stream a
- piEquivalenceClass :: Floating a => Stream a
- angleEquivalenceClass :: Floating a => a -> Stream a
Documentation
type RealClosure2 str a = (RealClosure str a, Limiting (str :*: str) a, Real (Closure (str :*: str) a)) Source #
stailStream :: Stream a -> Stream a Source #
sheadStrict :: Stream a -> a Source #
matrixPowers :: (SupportsMatrixMultiplication g g g a, Diagonalizable g a, LinearTransform g g a) => (g :*: g) a -> Stream ((g :*: g) a) Source #
compositions :: Stream (a -> a) -> Stream (a -> a) Source #
powerSeries_exp :: (Fractional a, Closed a) => Stream a -> Stream a Source #
matrixExponentialStream :: (Fractional (Scalar ((g :*: g) a)), Diagonalizable g a, LinearTransform g g a, SupportsMatrixMultiplication g g g a, InnerProductSpace (g a), VectorSpace ((g :*: g) a), Num ((g :*: g) a), Scalar (g (g a)) ~ Scalar (g a), Scalar (g a) ~ a, Scalar a ~ a) => (g :*: g) a -> Stream ((g :*: g) a) Source #
matrixExponential :: (Fractional (Scalar ((g :*: g) a)), SupportsMatrixMultiplication g g g a, Diagonalizable g a, LinearTransform g g a, InnerProductSpace (g a), VectorSpace ((g :*: g) a), Num ((g :*: g) a), Scalar (g (g a)) ~ Scalar (g a), Scalar (g a) ~ a, Scalar a ~ a) => (g :*: g) a -> (g :*: g) a Source #
cmap :: (Limiting s a, Limiting s b) => (a -> b) -> Closure s a -> Closure s b Source #
mapping operation for closures. Note we cannot make this a Functor instance due to constraint in the type.
cliftA2 :: (Limiting s a, Limiting s b, Limiting s c) => (a -> b -> c) -> Closure s a -> Closure s b -> Closure s c Source #
close :: Limiting Stream a => a -> Closure Stream a Source #
operation for producing a closure out of single element.
closure_limit :: (Num a, Closed a, Limiting Stream a) => Stream (Closure Stream a) -> Closure Stream a Source #
(.>>=.) :: (Limiting s a, Limiting s b) => Closure s a -> (a -> Closure s b) -> Closure s b Source #
Monadic bind operation for closures, again cannot be made instance of Monad.
eigenvector_by_power_iteration :: (Fractional (Scalar (m a)), NormedSpace (m a), LinearTransform m m a) => (m :*: m) a -> m a -> Stream (m a) Source #
taylor :: (Fractional a, DifferentiallyClosed a) => (a -> a) -> a -> (Stream :*: Stream) a Source #
stream_identityMatrix :: (Integral a, RealClosure2 Stream a) => (Stream :*: Stream) a Source #
This implementation of infinite identity matrix requires
Integral constraint.
it is not as efficient as identity
, but is implemented using
generating functions.
streamDiagonal :: Linearizable LinearMap (:*:) Stream Stream a => (Stream a :-> Stream a) -> Stream a Source #
stream_diagonal is the "depth-first" traversal over two-dimensional streams, where the choice always goes to diagonal elements.
stream_diagonal (matrix f x y) == liftA2 f x y
bindMatrix :: (ConjugateSymmetric a, Num a, Closed a) => (Stream a :-> Stream a) -> (a -> Stream a -> Stream a -> Stream b) -> Stream b Source #
bind diagonal element and horizontal and vertical strip
streamAs_diagonal :: (ConjugateSymmetric a, Num a, Closed a) => Stream a -> Stream a :-> Stream a Source #
stream matrix with a specified diagonal, other elements are zero.
add_column :: Applicative f => f a -> (f :*: Stream) a -> (f :*: Stream) a Source #
adding a column to a matrix.
add_column_endo :: Applicative f => f a -> Endo ((f :*: Stream) a) Source #
join3 :: (ConjugateSymmetric a, Num a, Closed a) => (Stream a :-> Stream a) -> Stream (a, a, a) Source #
adjusted_sequence_product :: Fractional a => Stream a -> Stream a -> Stream a Source #
average_seq :: Fractional a => Seq a -> a Source #
convolution_productMatrix :: (Functor m, Functor n, Num a) => (m :*: Stream) a -> (n :*: Stream) a -> (m :*: n) (Stream a) Source #
compose :: (ConjugateSymmetric a, Num a, Eq a) => Stream a -> Stream a -> Stream a Source #
For streams \(b = (b_i)_{i\in{\mathbf{N}}}\) and \(a = (a_i)_{i\in{\mathbf{N}}}\) representing generating functions \(g(z) = \sum_{i=0}^{\infty}{b_iz^i}\) and \(f(z) = \sum_{i=1}^{\infty}{a_iz^i}\) where \(a_0 = 0\), this computes: \[(g \circ f)(z) = g(f(z)) = \sum_{i=0}^{\infty}{b_i(f(z))^i} = \sum_{i=0}^{\infty}(b_i(\sum_{j=1}^{\infty}{a_jz^j})^i)\]
Note that identity of composition on the right is s_z
.
That is, \(s \circ s_z = s\).
https://en.wikipedia.org/wiki/Formal_power_series
matrixConvolution :: (SupportsMatrixMultiplication f g h a, VectorSpace ((f :*: h) a)) => Stream ((f :*: g) a) -> Stream ((g :*: h) a) -> Stream ((f :*: h) a) Source #
matrixConvolutionLinear :: (SupportsMatrixMultiplication f g h a, Linearizable LinearMap (:*:) g h a, Linearizable LinearMap (:*:) f g a, Linearizable LinearMap (:*:) f h a, VectorSpace ((f :*: h) a)) => Stream (f a :-> g a) -> Stream (g a :-> h a) -> Stream (f a :-> h a) Source #
matrixConvolutionProductLinear :: (Closed a, Fractional a, ConjugateSymmetric a) => (Stream a :-> Stream a) -> (Stream a :-> Stream a) -> Stream a :-> Stream a Source #
matrixConvolutionProduct :: (ConjugateSymmetric a, Fractional a) => (Stream :*: Stream) a -> (Stream :*: Stream) a -> (Stream :*: Stream) a Source #
computes average to normalize the matrix
distanceProduct :: (Floating a, ConjugateSymmetric a) => Stream a -> Stream a -> Stream a Source #
distance_product a b
computes \[l_k = \sqrt{\sum_{i+j=k}a_ib_j^{*}}\].
prefixMatrix :: a -> Stream a -> Stream a -> (Stream :*: Stream) a -> (Stream :*: Stream) a Source #
luDecompositionStreamMatrix :: (Floating a, Eq a) => (Stream :*: Stream) a -> ((Stream :*: Stream) a, (Stream :*: Stream) a, Stream Integer) Source #
https://en.wikipedia.org/wiki/LU_decomposition This has some bug still, lMatrix computation gets stuck.
cycleQueueBy :: (a -> b -> b) -> Queue a -> b Source #
cycleQueue :: Queue a -> Stream a Source #
convolveWithSeq :: Num a => (Seq a -> b) -> (c -> d -> a) -> Stream c -> Stream d -> Stream b Source #
data StreamIndex a Source #
Constructors
StreamIndex | |
Fields
|
Instances
streamfold :: (a -> b -> b) -> Fold (Stream a) b Source #
fold over streams
streamfold2 :: (a -> c -> b) -> (a -> b -> c) -> Fold (Stream a) b Source #
streamfoldLst :: [a -> b -> b] -> Fold (Stream a) b Source #
threeNplusOne :: Integer -> Integer Source #
the function studied in the Collatz conjecture.
fromIntegerSeq :: (Integer -> a) -> Stream a Source #
sumSeq :: (Num b, Num a, Ord a) => (a -> b) -> a -> Stream b Source #
\[[sumSeq(f)(n)]_j = \sum_{i=n}^{n+j+1}f(i)\]
streamindex :: Integer -> Stream a -> a Source #
streamQuotients :: Fractional a => Stream a -> Stream a Source #
matrix_inverse :: (ConjugateSymmetric (g2 a), LinearTransform (f2 :*: g1) (f2 :*: g1) (g2 a), FunctorArrow (f2 :*: g1) LinearMap LinearMap, InnerProductSpaceFunctor g1 (g2 a), InnerProductSpaceFunctor f2 (g2 a), Transposable f2 g1 (g2 a), Transposable g1 f2 (g2 a), Linearizable LinearMap (:*:) g1 f2 (g2 a), Linearizable LinearMap (:*:) f2 g1 (g2 a), Linearizable LinearMap (:*:) f2 g1 (g2 a), Num a, VectorSpace ((:*:) f2 g1 (g2 a)), Scalar (f2 (g2 a)) ~ g2 a, Scalar (g1 (g2 a)) ~ g2 a, Linearizable LinearMap (:*:) g2 g2 a, VectorSpace ((:*:) g2 g2 a), Diagonalizable g2 a) => (g1 (g2 a) :-> f2 (g2 a)) -> (f2 (g2 a) :-> g1 (g2 a)) -> Stream (f2 (g2 a) :-> g1 (g2 a)) Source #
liftStream2 :: (a -> a -> a) -> Stream a -> Stream a Source #
productStream :: Num a => Stream a -> Stream a Source #
productStream produce from a stream \([a_0,a_1,a_2,...]\) a stream \([a_0,a_0a_1,a_0a_1a_2,a_0a_1a_2a_3,...]\)
sumStream :: Num a => Stream a -> Stream a Source #
sumStream will produce from a stream \([a_0,a_1,a_2,...]\) a stream \([a_0,a_0+a_1,a_0+a_1+a_2,...]\).
vsumStream :: VectorSpace a => Stream a -> Stream a Source #
sumStreamIntegral :: (RealClosure Stream a, Integral a) => Stream a -> Stream a Source #
sumStreamFractional :: Fractional a => Stream a -> Stream a Source #
cobind :: (ConjugateSymmetric a, Num a, Closed a) => (a -> b) -> (Stream a :-> Stream a) -> Stream b Source #
if f
in cobind is a fixed-point free function, then this will find a
stream that is not an element of any of the streams.
streamCodiagonal :: Linearizable LinearMap (:*:) Stream Stream a => (Stream a :-> Stream a) -> Stream (Stream a, Stream a) Source #
Everything but a diagonal
zeroCodiagonal :: a -> Codiagonal Stream a Source #
streamMatrix :: Linearizable LinearMap (:*:) Stream Stream a => Stream a -> Stream (Stream a, Stream a) -> Stream a :-> Stream a Source #
streamMatrix creates matrix from a diagonal and a codiagonal
from_triangular_matrices :: Stream a -> (Stream :*: Stream) a -> (Stream :*: Stream) a -> (Stream :*: Stream) a Source #
this surprising function builds a two-dimensional infinite matrix from a diagonal, an upper triangular matrix and a lower triangular matrix. Notice the input matrices have no zero entries, rather indices for the triangular matrices are bijectively mapped to indices of the result matrix. This is only possible for infinite matrices. It's even more surprising once it's realised that two-dimensional infinite matrices can be bijectively described as an infinite binary tree of one-dimensional streams.
triangularMatrix_iso :: (Stream :*: Stream) a :==: ((Stream :*: Stream) a, Stream a, (Stream :*: Stream) a) Source #
isomorphism of infinite matrices that splits along diagonal.
triangularOrderMatrix :: Num a => (Stream :*: Stream) a Source #
this matrix contains 0 on diagonal, 1 on diagonal of upper and lower triangular matrices and so on. Every element of the two-dimensional matrix gets an index.
prefixStreamMatrix :: (ConjugateSymmetric a, Num a, Closed a) => a -> (Stream a, Stream a) -> (Stream a :-> Stream a) -> Stream a :-> Stream a Source #
pseudoCodiagonal :: (Stream :*: Stream) a -> Codiagonal Stream a Source #
mapMatrix :: (Num a, Num b) => (a -> b) -> ((Stream a, Stream a) -> (Stream b, Stream b)) -> (Stream :*: Stream) a -> (Stream :*: Stream) b Source #
sheadIndex :: Index Stream a Source #
dematrix :: (ConjugateSymmetric a, Num a, Closed a) => (Stream a :-> Stream a) -> (a, (Stream a, Stream a), Stream a :-> Stream a) Source #
codiagonals_linear :: (ConjugateSymmetric a, Num a, Closed a) => (Stream a :-> Stream a) -> Stream [a] Source #
codiagonals_list :: Num a => (Stream :*: Stream) a -> Stream [a] Source #
codiagonals operation implemented natively on lists.
This is not efficient due to use of list append (++) operation,
which is linear-time operation. Use codiagonals
function instead.
codiagonalsSeq :: (Stream :*: Stream) a -> Stream (Seq a) Source #
This is faster than the version for lists, because the suffix computation on Seq is constant time rather than linear. However, strictness seems to behave differently.
codiagonals :: (Stream :*: Stream) a -> Stream [a] Source #
The codiagonals
function will divide a two-dimensional
stream of streams (where elements are \(e_{(i,j)}\) into a stream of
lists
\(l_k\) where \(l_k = [e_{(i,j)} | i \leftarrow naturals, j \leftarrow naturals, i+j = k]\)
The indices in the streams are closely related to "Cantor pairing function" (which is a bijection)
f :: (N,N) -> N f(x,y) = (x+y)(x+y+1)/2 + x
Note that the list at each element of the resulting stream is of finite (but increasing) size. The order in each list is such that the diagonal elements are at the center of (the every second) list.
It is possible to think of this as "breadth-first" traversal over two-dimensional streams.
d x xr0 xr1 xr2 .. y d' x' xr0' xr1' .. yr0 y' yr1 yr0' yr2 yr1' ..
There is symmetry between primed and unprimed (e.g. d and d') towards the diagonal.
The resulting lists would be:
[d], [x,y], [xr0,d',yr0], [xr1,x',y',yr1],...
uncodiagonals :: Linearizable LinearMap (:*:) Stream Stream a => Stream [a] -> Stream a :-> Stream a Source #
for uncodiagonals, the i'th list element of the input stream must have length i
.
uncodiagonals ([a] `Pre` [b,c] `Pre` [d,e,f] ...)
== Pre (a `Pre` c `Pre` f ...) $
Pre (b `Pre` e `Pre` ...) $
Pre (d `Pre` ... ) $
...
split_dimension :: (ConjugateSymmetric a, Num a, Closed a) => Stream a -> Stream a :-> Stream a Source #
split_planar :: (ConjugateSymmetric a, Num a, Closed a) => Stream a -> Stream a :-> Stream a Source #
codiagonalsIso :: (ConjugateSymmetric a, Num a, Closed a, BiArrow arr) => arr (Stream a :-> Stream a) (Stream [a]) Source #
lowerTriangle :: Linearizable LinearMap (:*:) Stream Stream a => (Stream a :-> Stream a) -> Stream a :-> Stream a Source #
lowerTriangle takes lower half of a two-dimensional stream split at diagonal.
upperTriangle :: Linearizable LinearMap (:*:) Stream Stream a => (Stream a :-> Stream a) -> Stream a :-> Stream a Source #
upperTriangle takes upper half of a two-dimensional stream split at diagonal.
pairingMatrix :: Fractional a => (Stream :*: Stream) a Source #
concatenate :: Stream [a] -> Stream a Source #
concatenate a stream of lists to a stream of elements
diagonalize :: Stream [a] -> Stream a Source #
diagonalDifferences :: (ConjugateSymmetric a, Num a, Closed a) => (a -> b) -> (Stream a :-> Stream a) -> Stream b Source #
fixedpoint :: (ConjugateSymmetric a, Num a, Closed a, Eq a) => (a -> a) -> (Stream a :-> Stream a) -> a Source #
cojoin :: (Stream :*: Stream) a -> Stream a Source #
cojoin is "better" version of join for streams. cojoin does not satisfy monad laws (Right identity and associativity do not hold.). It eventually produces every element of the original two-dimensional stream. It first produces all elements \(e_{(i,j)}\) where \(i+j=k\) and \(k\) increasing.
(|*|) :: Closed a => Stream a -> Stream a -> Stream (Vector2 a) Source #
naturals |*| naturals == (0,0), [note sum=0] (0,1),(1,0), [note sum=1] (0,2),(2,0),(1,1), [note sum=2] (0,3),(3,0),(1,2),(2,1), [note sum=3] (0,4),(4,0),(1,3),(3,1),(2,2), [note sum=4] ...
(>>!=) :: Num b => Stream a -> (a -> Stream b) -> Stream b Source #
For a better "bind" operation, there exists (>>!=), which produces the following result (note duplicates):
naturals >>!= \x -> naturals >>!= \y -> return (x,y) == (0,0), (0,0),(1,0), (0,1),(1,0),(2,0), (0,0),(1,1),(2,0),(3,0), (0,1),(1,0),(2,1),(3,0),(4,0), (0,2),(1,1),(2,0),(3,1),(4,0),(5,0), (0,0),(1,2),(2,1),(3,0),(4,1),(5,0),(6,0), (0,1),(1,0),(2,2),(3,1),(4,0),(5,1),(6,0),(7,0), (0,2),(1,1),(2,0),(3,2),(4,1),(5,0),(6,1),(7,0),(8,0), (0,3),(1,2),(2,1),(3,0),(4,2),(5,1),(6,0),(7,1),(8,0),(9,0), ...
(>!=) :: Num b => Stream a -> (a -> Stream b) -> Stream [b] Source #
The (>!=) is like binding, but the results are packaged to a finite list. Again note duplicates.
naturals >!= \x -> naturals >!= \y -> return (x,y) == [[(0,0)] ], [[(0,0),(0,1)], [(1,0)] ], [[(0,0),(0,1),(0,2)], [(1,0),(1,1)], [(2,0)], ], [[(0,0),(0,1),(0,2),(0,3)], [(1,0),(1,1),(1,2)], [(2,0),(2,1)], [(3,0)] ], ...
integersStream :: Stream Integer Source #
A stream of integers. This is specialized version of naturals for integers
naturals_starting_from :: (Num a, Ord a) => a -> Stream a Source #
A stream of increasing numbers starting from a given number.
nonzeroNaturals :: Num a => Stream a Source #
A stream of increasing numbers starting from 1
s_z :: Num a => Stream a Source #
This is the variable used in generating functions. Note that in multidimensional streams, this is the variable associated with the largest dimension.
s_z3 :: Num a => Stream (Stream (Stream a)) Source #
variable associated with third largest dimension
streamLogarithm :: Fractional a => Stream a -> Stream a Source #
approximateSums :: Fractional a => Stream a -> Stream a -> Stream a Source #
For a stream of terms \(a=[a_0,a_1,a_2,...]\), and \(x=[x_0,x_1,x_2,...]\), 'approximateSums a x' computes \[\sum_{i=0}^n{a_ix_i^i}\], where n is the index to the result stream.
exponentialStream :: Fractional a => Stream a Source #
exponentialStream computes \(s_{i} = {{1}\over{i!}}\).
notice that euler's constant \(e = \sum_{i=0}^{\infty}{1\over{i!}}\).
therefore "sumStream exponentialStream" produces approximations to e
.
exponential :: (ConjugateSymmetric a, Eq a, Fractional a) => Stream a -> Stream a Source #
logGeneratingFunction :: Fractional a => Stream a Source #
sinGeneratingFunction :: Fractional a => Stream a Source #
cosGeneratingFunction :: Fractional a => Stream a Source #
reciprocal :: Fractional a => Stream a -> Stream a Source #
both reciprocal and inversion are the inverse of a Cauchy product. see http://en.wikipedia.org/wiki/Formal_power_series
reciprocal s * s == unit_product
inversion :: Integral a => Stream a -> Stream a Source #
see http://en.wikipedia.org/wiki/Formal_power_series
inversion s * s == unit_product
.
unitProduct :: Num a => Stream a Source #
unit_product is the unit element of (*) for streams.
fromList :: Num a => [a] -> Stream a Source #
The cycle
operation is better than fromList
, if the list is infinite,
because it will ensure the result is infinite (and no Num constraint is needed).
filter :: (a -> Bool) -> Stream a -> Stream a Source #
filter f s
for streams does not terminate, if the input stream never
contains any elements e
for which f e == True
.
interleaveCount :: Integer -> Stream a -> Stream a -> Stream a Source #
interleave_count
is like interleave
except that i
elements of each
stream are taken from each stream at each stream.
interleaveStream :: Stream a -> Stream a -> Stream a Source #
interleave two streams such that even indexed elements of result are from first input stream and odd indexed elements of result are from second stream.
interleaveEither :: Stream a -> Stream b -> Stream (Either a b) Source #
version of interleave that produces either instances
uninterleave :: Stream a -> (Stream a, Stream a) Source #
split a stream, elements with even index go to first result stream, rest to second.
interleaveLst :: [Stream a] -> Stream a Source #
interleave a non-empty list of streams.
uninterleaveLst :: Integer -> Stream a -> [Stream a] Source #
uninterleave to an indicated number of streams.
uninterleaveQueue :: Integer -> Stream a -> (Queue :*: Stream) a Source #
uninterleave to a queue of streams
drop :: Integer -> Stream a -> Stream a Source #
drop a specified number of elements from beginning of a stream.
take :: Integer -> Stream a -> [a] Source #
take a specified number of elements from the beginning of the stream.
countWhile :: (a -> Bool) -> Stream a -> Integer Source #
count how many elements from a beginning of a stream satisfy a predicate.
takeWhile :: (a -> Bool) -> Stream a -> [a] Source #
take elements from a stream while predicate is true.
dropWhile :: (a -> Bool) -> Stream a -> Stream a Source #
drop elements from a stream while predicate is true.
cycle :: [a] -> Stream a Source #
The cycle
operation is better than fromList for converting a list to stream,
if the list is infinite, because it will ensure the result is infinite.
cycledQueue :: Queue a -> Stream a Source #
use elements of a queue to produce an infinite stream.
stirlingNumbers :: Num a => (Stream :*: Stream) a Source #
stirling numbers are the numbers obtained from \(z (z+1) ... (z+n)\)
naturalPrefixes :: Num a => Stream [a] Source #
power :: Fractional a => Integer -> Stream a Source #
stream of powers of a given integer for fractional items
powerUniformFractional :: Fractional a => a -> Stream a Source #
powerIntegral :: Integral a => Integer -> Stream a Source #
stream of powers of a given integer for integral items.
powerUniformIntegral :: Integral a => a -> Stream a Source #
expGeneratingFunction :: (ConjugateSymmetric a, Closed a, Floating a, Eq a) => Stream a Source #
exponentialGeneratingFunction :: Fractional a => Stream a -> Stream a Source #
https://en.wikipedia.org/wiki/Generating_function. \[EGF(z \mapsto \sum_{k=0}^{\infty}{s_kz^k}) = z \mapsto \sum_{k=0}^{\infty}{{1\over{k!}}{s_kz^k}}\].
poissonGeneratingFunction :: (ConjugateSymmetric a, Closed a, Eq a, Floating a) => Stream a -> Stream a Source #
powers :: Num a => Stream a -> (Stream :*: Stream) a Source #
input stream elements are raised to n'th power.
cauchyPowers :: Num a => a -> Stream a Source #
input element is raised to successive increasing powers (first element of the stream is \(n^1\))
binomialCoefficient :: (Integral a, RealClosure2 Stream a) => Integer -> Integer -> a Source #
The elements of pascal triangle are binomial coefficients.
catalanNumbers :: (Integral a, RealClosure Stream a) => Stream a Source #
catalanNumbersFloating :: (ConjugateSymmetric a, Closed a, Eq a, Floating a) => Stream a Source #
http://en.wikipedia.org/wiki/Catalan_number of floating elements.
pascalTriangle :: (Integral a, RealClosure2 Stream a) => (Stream :*: Stream) a Source #
pascal triangle, elements are binomial coefficients. https://en.wikipedia.org/wiki/Pascal%27s_triangle this expands "down" (leaving zero elements)
pascalTriangleDiag :: (Integral a, RealClosure2 Stream a) => (Stream :*: Stream) a Source #
pascal triangle which expands towards the diagonal
pascalTriangleDiagFractional :: Fractional a => (Stream :*: Stream) a Source #
binomialCoefficients :: (Integral a, RealClosure2 Stream a) => Stream [a] Source #
binomialCoefficientsSeq :: (Integral a, RealClosure2 Stream a) => Stream (Seq a) Source #
expApprox :: (Fractional a, RealClosure2 Stream a) => a -> Stream a Source #
polynomialPowers :: (Integral a, RealClosure2 Stream a) => a -> a -> Stream a Source #
computes \((a + b)^n\) for all n, using binomial coefficients.
Hint: use z
in one of the argument.
pascalTriangle == Matrix $ polynomial_powers 1 z
Note: stream_powers can sometimes be a more efficient alternative.
polynomialPowersFractional :: Fractional a => a -> a -> Stream a Source #
fib :: (Integral a, RealClosure Stream a) => Stream a Source #
a stream of fibonacci numbers,
each element is a sum of two previous elements.
1,1,2,3,5,8,13,21,34,55,...
triangularNumbers :: (Integral a, RealClosure Stream a) => Stream a Source #
Triangular numbers. https://en.wikipedia.org/wiki/Generating_function
1,3,6,10,15,21,28,36,...
alternatingSigns :: Fractional a => Stream a Source #
1.0,-1.0,1.0,-1.0,...
alternatingBits :: Fractional a => Stream a Source #
1.0,0.0,1.0,0.0,1.0,0.0,...
alternatingPossiblyNegativeBits :: Fractional a => Stream a Source #
oddIntegers :: Integral a => Stream a Source #
stream of odd integers
integersDivisibleBy :: Integer -> Stream Integer Source #
This is an ideal of the set of positive integers, usually denoted \(nZ^+\),
e.g. set of positive integers divisible by n
.
residueClassModulo :: Integer -> Integer -> Stream Integer Source #
This function produces the equivalence class of m mod n. The numbers produced by the stream are considered as equivalent by the equivalence class.
peircesTriangleFunc :: (Num a, Ord a) => a -> a -> a Source #
peircesTriangle is the number of set partitions. From Knuth: The art of Computer Programming, Volume 4 "Generating all combinations and partitions", page 64.
peircesTriangle :: (Num a, Ord a) => (Stream :*: Stream) a Source #
peircesTriangle is the number of set partitions. From Knuth: The art of Computer Programming, Volume 4 "Generating all combinations and partitions", page 64.
fallingFactorialPowersDiag :: (Real (Closure Stream a), Real (Closure (Stream :*: Stream) a), ConjugateSymmetric a, Integral a, Closed a) => Stream a :-> Stream a Source #
https://en.wikipedia.org/wiki/Injective_function?wprof=sfla1 falling factorial powers specify number of injective functions from domain with specified number of elements to codomain with specified number of elements. https://en.wikipedia.org/wiki/Falling_and_rising_factorials?wprof=sfla1
Be careful about indices here, could cause off-by-one error!
bell_numbers :: (Num a, Ord a) => Stream a Source #
bell numbers https://en.wikipedia.org/wiki/Bell_number. also see Knuth: The Art of Computer Programming, Volume 4.
squareRoot :: Integral a => a -> Stream a Source #
newton's method of computing square root approximations:
fractionalSquareRoot :: (Fractional a, Eq a) => a -> Stream a Source #
detectCycle :: Eq a => Stream a -> [a] Source #
This is an implementation of Floyd's cycle-finding algorithm http://en.wikipedia.org/wiki/Cycle_detection.
derivative :: Num a => Stream a -> Stream a Source #
derivative calculates the derivative of the generating function. https://en.wikipedia.org/wiki/Generating_function \[{\rm{derivative}}({\bf{a}})_i = {\bf{b}}_i = (i+1){\bf{a}}_{i+1}\] \[f(z) = \sum_{i=0}^{\infty}{\bf{a}}_iz^i\] \[f'(z) = \sum_{i=0}^{\infty}{\bf{b}}_iz^i = {d\over{dz}} \sum_{i=0}^{\infty}{\bf{a}}_iz^i = \sum_{i=0}^{\infty}(i+1){\bf{a}}_{i+1}z^i\]
monotonicMembership :: Ord a => Stream a -> Stream a -> Stream Bool Source #
for two monotone streams, compares whether all elements of the first stream
are also in the second stream. produces True
for every element of
the first stream, if that element is part of the second stream.
produces error if the streams are not monotone.
sqrtStream :: Floating a => Stream a -> Stream a Source #
Square root algorithm is from Simpson: Power Series, http://caps.gsfc.nasa.gov/simpson/ref/series.pdf
cosStreamRealFloat :: (RealFloat a, Infinitesimal Stream a) => Stream a -> Stream a Source #
sinStreamRealFloat :: (RealFloat a, Infinitesimal Stream a) => Stream a -> Stream a Source #
streamEpsilon :: (ConjugateSymmetric a, Closed a, Fractional a) => Stream a :-> Stream a Source #
anotherEpsilon :: (ConjugateSymmetric a, Closed a, Fractional a) => Stream a :-> Stream a Source #
streamDerivate :: (Fractional a, Closed a, Infinitesimal str (Stream a)) => (Stream a -> Stream a) -> Stream a -> Closure str (Stream a) Source #
derivate a stream function at a particular point.
streamIntegral :: (Closed b, Infinitesimal str (Stream b), Fractional b, Enum b) => (Stream b -> Stream b) -> (Stream b, Stream b) -> Closure str (Stream b) Source #
streamPi :: (Infinitesimal str (Stream a), ConjugateSymmetric a, Closed a, Fractional a, Enum a, Eq a, Floating a) => Closure str (Stream a) Source #
gcd_primes :: Integral a => Stream a Source #
gcd_prime_gen :: Integral a => a -> a Source #
vectorEpsilon :: Infinitesimal Stream a => Stream (Vector3 a) Source #
derivativeCoefficientsFractional :: Fractional a => (Stream :*: Stream) a Source #
derivativeLinearMap :: (ConjugateSymmetric a, Closed a) => Stream a :-> Stream a Source #
bernoulliMinus :: Fractional a => Integer -> a Source #
bernoulliPlus :: Fractional a => Integer -> a Source #
bernoulli :: Fractional a => Stream a Source #
bernoulliPolynomial :: Fractional b => b -> Integer -> b Source #
bernoulliPolynomials :: Fractional a => (Stream :*: Stream) a Source #
bernoulliPolynomialCoefficients :: Fractional a => Stream [a] Source #
legendrePolynomials :: (Eq a, ConjugateSymmetric a, Floating a) => (Stream :*: Stream) a Source #
legendrePolynomialLists :: (Num a, Eq a, ConjugateSymmetric a, Floating a) => Stream [a] Source #
evaluatePolynomial :: Fractional a => [a] -> a -> a Source #
evaluateLegendrePolynomial :: (Fractional a, Eq a, ConjugateSymmetric a, Floating a) => Integer -> a -> a Source #
evaluateLegendreAt :: (Fractional a, Eq a, ConjugateSymmetric a, Floating a) => a -> Stream a Source #
circlePeriods :: Floating a => Stream a Source #
circle_periods returns a stream of ${2pi n | n in N+}$ in increasing order.
piEquivalenceClass :: Floating a => Stream a Source #
members of equivalence class $[pi] = {pi + 2pi n | n in N}$.
angleEquivalenceClass :: Floating a => a -> Stream a Source #
members of equivalence class $[alpha] = {alpha + 2pi n | n in N}$. Notice that angles smaller than $alpha$ are not produced.