Commits

Aleksey Khudyakov  committed d026d11

Add constructor

  • Participants
  • Parent commits 42a315d

Comments (0)

Files changed (1)

File Numeric/Tools/Mesh.hs

     Mesh(..)
     -- ** Uniform mesh
   , UniformMesh
+  , uniformMeshStep
+    -- *** Constructors
   , uniformMesh
-  , uniformMeshStep
+  , uniformMeshN
   ) where
 
 import Data.Data          (Data,Typeable)
   | n <  2    = error "Numeric.Tool.Interpolation.Mesh.uniformMesh: too few points"
   | otherwise = UniformMesh a ((b - a) / fromIntegral (n - 1)) n
 
+-- | Create uniform mesh
+uniformMeshN :: Double  -- ^ Lower bound
+             -> Double  -- ^ Mesh step
+             -> Int     -- ^ Number of points
+             -> UniformMesh
+uniformMeshN a dx n
+  | n  <  2   = error "Numeric.Tool.Interpolation.Mesh.uniformMeshStep: too few points"
+  | dx <= 0   = error "Numeric.Tool.Interpolation.Mesh.uniformMeshStep: nonpositive step"
+  | otherwise = UniformMesh a dx n
+
 
 instance Indexable UniformMesh where
   type IndexVal UniformMesh = Double