LibraryDataType[datatype]
specifies the data type for a LibraryFunction argument or result to be datatype.
LibraryDataType[datatype,etype]
specifies an element type etype for data structures.
LibraryDataType[datatype,etype,d]
specifies an array depth d for array data types.
LibraryDataType
LibraryDataType[datatype]
specifies the data type for a LibraryFunction argument or result to be datatype.
LibraryDataType[datatype,etype]
specifies an element type etype for data structures.
LibraryDataType[datatype,etype,d]
specifies an array depth d for array data types.
Details
- Possible library data types include:
-
Null Null type (void) True | False Boolean values (mbool) String UTF8 encoded strings (char *) Integer machine integers (mint) Real machine reals (mreal) Complex machine complex numbers (mcomplex) List tensors of numerical values (MTensor) NumericArray numeric arrays for LibraryLink (MNumericArray) SparseArray sparse arrays of numerical values for LibraryLink (MSparseArray) ByteArray byte arrays for LibraryLink (MNumericArray) Image 2D images for LibraryLink (MImage) Image3D 3D images for LibraryLink (MImage) Image|Image3D 2D or 3D images for LibraryLink (MImage) - For an image datatype, LibraryDataType[datatype,itype] specifies an ImageType of itype; LibraryDataType[datatype] allows any image type.
Examples
open all close allBasic Examples (1)
Load an example LibraryFunction that accepts a sparse array argument:
props = LibraryFunctionLoad["demo_sparse", "sparse_properties", {"UTF8String", {LibraryDataType[SparseArray]}}, {_, _}];Use the function to get a property from a sparse array:
s = SparseArray[{{1, 0, 0}, {2 , 0, 3}}];props["ExplicitPositions", s]Scope (2)
Load an example LibraryFunction that returns Image of type "Real64":
colorNegate = LibraryFunctionLoad["demo_image", "color_negate", {{LibraryDataType[Image], "Constant"}}, {LibraryDataType[Image, "Real64"]}];Use the function to get the result:
colorNegate[RandomImage[1, 10, "Real64"]]This function preserves the type of input argument, so it fails to return the result for types different than "Real64":
colorNegate[RandomImage[1, 10, "Real32"]]Load an example LibraryFunction that returns a two-dimensional NumericArray of type "ComplexReal64":
numericArrayComplexConjugate = LibraryFunctionLoad["demo_numericarray", "numericArrayComplexConjugate", {{LibraryDataType[NumericArray], "Constant"}}, {LibraryDataType[NumericArray, "ComplexReal64", 2]}];Use the function to get the result:
complex64 = NumericArray[RandomComplex[{-1 - I, 1 + I}, {2, 3}], "ComplexReal64"];numericArrayComplexConjugate[complex64]This function preserves the type of input argument, so it fails to return the result for types different than "ComplexReal64":
complex32 = NumericArray[RandomComplex[{-1 - I, 1 + I}, {2, 3}], "ComplexReal32"];numericArrayComplexConjugate[complex32]This function preserves the rank of the input argument, so it fails to return the result for ranks different than 2:
complex1D = NumericArray[RandomComplex[{-1 - I, 1 + I}, 3], "ComplexReal64"];numericArrayComplexConjugate[complex1D]See Also
Text
Wolfram Research (2014), LibraryDataType, Wolfram Language function, https://reference.wolfram.com/language/ref/LibraryDataType.html (updated 2019).
CMS
Wolfram Language. 2014. "LibraryDataType." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/LibraryDataType.html.
APA
Wolfram Language. (2014). LibraryDataType. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LibraryDataType.html
BibTeX
@misc{reference.wolfram_2026_librarydatatype, author="Wolfram Research", title="{LibraryDataType}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/LibraryDataType.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_librarydatatype, organization={Wolfram Research}, title={LibraryDataType}, year={2019}, url={https://reference.wolfram.com/language/ref/LibraryDataType.html}, note=[Accessed: 12-June-2026]}