Package uk.ac.starlink.array
Class CombineArrayImpl
java.lang.Object
uk.ac.starlink.array.CombineArrayImpl
- All Implemented Interfaces:
ArrayImpl
Virtual NDArray implementation combining two given NDArrays using an
arbitrary arithmetic function. Each pixel in the resulting array
is the result of combining the two corresponding pixels of the input
arrays using a supplied
Combiner object.
Type conversions are taken care of, and values which end up outside
the range of the type of the resulting array are automatically
turned Bad.- Author:
- Mark Taylor (Starlink)
-
Constructor Summary
ConstructorsConstructorDescriptionCombineArrayImpl(NDArray nda1, NDArray nda2, Combiner combi, NDShape shape, Type type, BadHandler bh) Construct a new CombineArrayImpl based on two underlying NDArrays and a combiner object. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanMap()Indicates whether mapped access is available.voidclose()Shuts down this ArrayImpl for pixel access.Returns an object which can access the pixels of this ArrayImpl.The magic bad value for data.Returns a single primitive array holding all the pixel data of this array.getShape()Returns an object representing the shape (origin and dimensions) and pixel sequence of this object.getType()Returns the primitive type of the data held by this object.booleanisRandom()Indicates whether random access is possible.booleanIndicates whether read access is possible.booleanIndicates whether write access is possible.booleanIndicates whether the getAccess method may be called more than once.voidopen()Prepares this ArrayImpl for pixel access.
-
Constructor Details
-
CombineArrayImpl
public CombineArrayImpl(NDArray nda1, NDArray nda2, Combiner combi, NDShape shape, Type type, BadHandler bh) Construct a new CombineArrayImpl based on two underlying NDArrays and a combiner object. The supplied array objects do not need to be the same type or shape or the same type or shape as the resulting array object. Values outside the shape of one or the other will be presented as a Bad value to the Combiner object.- Parameters:
nda1- the first array to combinenda2- the second array to combinecombi- the object which performs the arithmetic combinationshape- the shape of the resulting array objecttype- the type of the resulting array objectbh- the bad value handler for the resulting array object. Ifnull, a non-null bad value handler using a default value is used.
-
-
Method Details
-
getShape
Description copied from interface:ArrayImplReturns an object representing the shape (origin and dimensions) and pixel sequence of this object. The return value must not change over the lifetime of the object. -
getType
Description copied from interface:ArrayImplReturns the primitive type of the data held by this object. The return value must not change over the lifetime of the object. -
getBadValue
Description copied from interface:ArrayImplThe magic bad value for data. The returned type should be one of the primitive wrapper types, Byte, Short, Integer, Float, Double as appropriate for the type of this array. It may benullif there is no bad value. The return value must not change over the lifetime of the object.- Specified by:
getBadValuein interfaceArrayImpl- Returns:
- the bad value
-
isReadable
public boolean isReadable()Description copied from interface:ArrayImplIndicates whether read access is possible. Reads will only be attempted if this method returns true. The return value must not change over the lifetime of the object.- Specified by:
isReadablein interfaceArrayImpl- Returns:
- whether read access is available
-
isWritable
public boolean isWritable()Description copied from interface:ArrayImplIndicates whether write access is possible. Writes will only be attempted if this method returns true. The return value must not change over the lifetime of the object.- Specified by:
isWritablein interfaceArrayImpl- Returns:
- whether write access is available
-
isRandom
public boolean isRandom()Description copied from interface:ArrayImplIndicates whether random access is possible. If this method returns true, then it is permissible to set the offset to a value lower than its current value. If it is false, then no such invocations will be attempted. The return value must not change over the lifetime of the object. -
multipleAccess
public boolean multipleAccess()Description copied from interface:ArrayImplIndicates whether the getAccess method may be called more than once.- Specified by:
multipleAccessin interfaceArrayImpl- Returns:
- true if getAccess may be called more than once
-
open
Description copied from interface:ArrayImplPrepares this ArrayImpl for pixel access. This method will be called no more than once, and it will be called prior to any calls of the getAccess method.- Specified by:
openin interfaceArrayImpl- Throws:
IOException- if there is an IO error
-
canMap
public boolean canMap()Description copied from interface:ArrayImplIndicates whether mapped access is available. If true, then following an open call, the getMapped method will return a reference to the java primitive array containing all the pixels of this array.Will only be called after an open call, and before any close call.
-
getMapped
Description copied from interface:ArrayImplReturns a single primitive array holding all the pixel data of this array. This should be a cheap operation, returning a reference to an existing array rather than doing work to generate one. In the case of a writable accessor, making changes to the returned primitive array will result in changes to the accessor pixel data. In the case of an NDArray which is not writable, the effect of making changes to the returned array is undefined; in particular it may result in an exception.Will only be called if canMap returns true, and only after an open call and before any close call.
-
getAccess
Description copied from interface:ArrayImplReturns an object which can access the pixels of this ArrayImpl. Each call to this method returns a new and independent AccessImpl, with an offset initialised to 0 (the start of the array data).This method will only be called after the sole call to open and before the sole call to close.
This method will only be called more than once if the multipleAccess method returns true.
It is the responsibility of the caller to close the returned AccessImpl when it is no longer required; this enables resources it may hold to be released.
- Specified by:
getAccessin interfaceArrayImpl- Returns:
- an accessor for the pixel data
- Throws:
IOException- if there is an IO error
-
close
Description copied from interface:ArrayImplShuts down this ArrayImpl for pixel access. This method will be called no more than once. No calls to getAccess, getMapped or open will be made after it is called. If the user makes proper use of the NDArray classes, it will be called after any AccessImpl objects and references to the mapped array are no longer required. If the user misbehaves however it may not get called at all, so an effort should be made to realease non-memory resources and flush buffers where appropriate in the finalizer.- Specified by:
closein interfaceArrayImpl- Throws:
IOException- if there is an IO error
-