Main Content

matlab::data::Reference<SparseArray<T>>

Templated C++ class to get reference to SparseArray

Description

Use the Reference<SparseArray> class to get a reference to a SparseArray element of a container object, such as a MATLAB® structure or cell array.

Class Details

Namespace:

matlab::data

Include:

SparseArrayRef.hpp

Template Parameters

T

Type of elements in SparseArray, specified as bool, double, or std::complex<double>.

Iterators

Begin Iterators

iterator begin()

const_iterator begin() const

const_iterator cbegin() const

Returns

iterator

Iterator to beginning of array, specified as TypedIterator<T>.

const_iterator

Iterator, specified as TypedIterator<typename std::add_const<T>::type>.

Throws

None

End Iterators

iterator end()

const_iterator end() const

const_iterator cend() const

Returns

iterator

Iterator to beginning of array, specified as TypedIterator<T>.

const_iterator

Iterator, specified as TypedIterator<typename std::add_const<T>::type>.

Throws

None

Member Functions

getNumberOfNonZeroElements

size_t getNumberOfNonZeroElements() const
Description

Returns the number of nonzero elements in the array. Since sparse arrays only store nonzero elements, this method returns the actual array size. It is different from array dimensions that specify the full array size.

Returns

size_t

Number of nonzero elements in the array.

Throws

None

Version History

Introduced in R2017b