Safe Haskell | None |
---|---|
Language | Haskell2010 |
Array access, including cell arrays and structures.
Functions here are primarily thin wrappers to the underlying Matlab functions, and the same memory-management semantics hold.
In particular, created arrays must be freed, copyMXArray
and freeMXArray
are deep operations, other set operations do not make copies.
- anyMXArray :: MXArray a -> MAnyArray
- type MNullArray = MXArray MNull
- castMNull :: MAnyArray -> MIO (Maybe MNullArray)
- mxArrayClass :: MXArray a -> IO MXClass
- mxArrayIsComplex :: MXArray a -> IO Bool
- mxArraySize :: MXArray a -> MIO MSize
- mxArraySetSize :: MXArray a -> MSize -> IO ()
- mxArrayLength :: MXArray a -> MIO Int
- freeMXArray :: MXArray a -> MIO ()
- copyMXArray :: MXArray a -> MIO (MXArray a)
- mIndexOffset :: MXArray a -> MIndex -> MIO Int
- class MXArrayComponent a where
- createMXArray :: MSize -> MIO (MXArray a)
- isMXScalar :: MXArray a -> MIO Bool
- mxArrayGetOffset :: MXArray a -> Int -> MIO a
- mxArraySetOffset :: MXArray a -> Int -> a -> MIO ()
- mxArrayGetOffsetList :: MXArray a -> Int -> Int -> MIO [a]
- mxArraySetOffsetList :: MXArray a -> Int -> [a] -> MIO ()
- mxScalarGet :: MXArray a -> MIO a
- createMXScalar :: a -> MIO (MXArray a)
- createColVector :: [a] -> MIO (MXArray a)
- createRowVector :: [a] -> MIO (MXArray a)
- castMXArray :: forall a. MXArrayComponent a => MAnyArray -> MIO (Maybe (MXArray a))
- mxArrayGet :: MXArrayComponent a => MXArray a -> MIndex -> MIO a
- mxArraySet :: MXArrayComponent a => MXArray a -> MIndex -> a -> MIO ()
- mxArrayGetList :: MXArrayComponent a => MXArray a -> MIndex -> Int -> MIO [a]
- mxArraySetList :: MXArrayComponent a => MXArray a -> MIndex -> [a] -> MIO ()
- mxArrayGetAll :: MXArrayComponent a => MXArray a -> IO [a]
- mxArraySetAll :: MXArrayComponent a => MXArray a -> [a] -> IO ()
- type MStructArray = MXArray MStruct
- createStruct :: MSize -> [String] -> MIO MStructArray
- mStructFields :: MStructArray -> MIO [String]
- mStructGet :: MStructArray -> MIndex -> String -> MIO MAnyArray
- mStructSet :: MStructArray -> MIndex -> String -> MXArray a -> MIO ()
- mStructSetFields :: MStructArray -> MIndex -> [MXArray a] -> MIO ()
- mStructAddField :: MStructArray -> String -> MIO ()
- mStructRemoveField :: MStructArray -> String -> MIO ()
- mObjectGetClass :: MStructArray -> IO (Maybe String)
- mObjectSetClass :: MStructArray -> String -> IO ()
Array manipulation
anyMXArray :: MXArray a -> MAnyArray Source
(Un)cast an array to a generic type.
type MNullArray = MXArray MNull Source
A NULL (empty) array
castMNull :: MAnyArray -> MIO (Maybe MNullArray) Source
Safely cast a generic array to a NULL array, or return Nothing if the array is not NULL
mxArrayClass :: MXArray a -> IO MXClass Source
Return the representation of the type of the elements of an array
mxArrayIsComplex :: MXArray a -> IO Bool Source
mxArraySize :: MXArray a -> MIO MSize Source
Get the size (dimensions) of an array
mxArraySetSize :: MXArray a -> MSize -> IO () Source
Set dimension array and number of dimensions
mxArrayLength :: MXArray a -> MIO Int Source
freeMXArray :: MXArray a -> MIO () Source
Destroy an array and all of its contents.
copyMXArray :: MXArray a -> MIO (MXArray a) Source
Make a deep copy of an array
Array element access
class MXArrayComponent a where Source
The class of standardly typeable array elements
createMXArray :: MSize -> MIO (MXArray a) Source
Create an array and initialize all its data elements to some default value, usually 0 or []
isMXScalar :: MXArray a -> MIO Bool Source
Determine if an array is singleton. Equivalent to
liftM (all (1 ==)) . mxArraySize
mxArrayGetOffset :: MXArray a -> Int -> MIO a Source
mxArraySetOffset :: MXArray a -> Int -> a -> MIO () Source
mxArrayGetOffsetList :: MXArray a -> Int -> Int -> MIO [a] Source
mxArraySetOffsetList :: MXArray a -> Int -> [a] -> MIO () Source
mxScalarGet :: MXArray a -> MIO a Source
Get the value of the first data element in an array or, more specifically, the value that the array will be interpreted as in scalar context
createMXScalar :: a -> MIO (MXArray a) Source
Create a singleton (scalar) array having the specified value
createColVector :: [a] -> MIO (MXArray a) Source
Create a column vector from the given list.
createRowVector :: [a] -> MIO (MXArray a) Source
Create a row vector from the given list.
castMXArray :: forall a. MXArrayComponent a => MAnyArray -> MIO (Maybe (MXArray a)) Source
Safely cast a generic array to a type, or return Nothing if the array does not have the proper type
array element access
mxArrayGet :: MXArrayComponent a => MXArray a -> MIndex -> MIO a Source
Get the value of the specified array element. Does not check bounds.
mxArraySet :: MXArrayComponent a => MXArray a -> MIndex -> a -> MIO () Source
Set an element in an array to the specified value. Does not check bounds.
array list access
mxArrayGetList :: MXArrayComponent a => MXArray a -> MIndex -> Int -> MIO [a] Source
gets the sequential list of mxArrayGetList
a i nn
items from array a
starting at index i
. Does not check bounds.
mxArraySetList :: MXArrayComponent a => MXArray a -> MIndex -> [a] -> MIO () Source
sets the sequential items in array mxArraySetList
a i la
starting at index i
to l
. Does not check bounds.
mxArrayGetAll :: MXArrayComponent a => MXArray a -> IO [a] Source
Get a flat list of all elements in the array.
mxArraySetAll :: MXArrayComponent a => MXArray a -> [a] -> IO () Source
Set a flat list of all elements in the array.
Struct access
Structs in Matlab are always arrays, and so can be accessed using most array accessors.
|However, the modification functions such as mxArraySet
are not implemented because they could disrupt field data in the entire struct array, and so some specialized functions are necessary.
type MStructArray = MXArray MStruct Source
A (array of) structs
createStruct :: MSize -> [String] -> MIO MStructArray Source
Create an N-Dimensional structure array having the specified fields; initialize all values to MNullArray
mStructFields :: MStructArray -> MIO [String] Source
Get the names of the fields
mStructGet :: MStructArray -> MIndex -> String -> MIO MAnyArray Source
Return the contents of the named field for the given element. Returns MNullArray
on no such field or if the field itself is NULL
mStructSet :: MStructArray -> MIndex -> String -> MXArray a -> MIO () Source
Sets the contents of the named field for the given element. The input is stored in the array -- no copy is made.
mStructSetFields :: MStructArray -> MIndex -> [MXArray a] -> MIO () Source
Set the fields of a struct index to the given value list. The list corresponds to the field list and must match in size.
mStructAddField :: MStructArray -> String -> MIO () Source
Add a field to a structure array.
mStructRemoveField :: MStructArray -> String -> MIO () Source
Remove a field from a structure array. Does nothing if no such field exists.
Object access
Some structs are also validated (blessed) user objects.
mObjectGetClass :: MStructArray -> IO (Maybe String) Source
Determine if a struct array is a user defined object, and return its class name, if any.
mObjectSetClass :: MStructArray -> String -> IO () Source
Set classname of an unvalidated object array. It is illegal to call this function on a previously validated object array.