Matrix em = model.getEmissionMatrix();
Matrix tr = model.getTransitionMatrix();
// allocate the sparse data structures
RandomAccessSparseVector sparseIp = new RandomAccessSparseVector(model
.getNrOfHiddenStates());
SparseMatrix sparseEm = new SparseMatrix(new int[]{
model.getNrOfHiddenStates(), model.getNrOfOutputStates()});
SparseMatrix sparseTr = new SparseMatrix(new int[]{
model.getNrOfHiddenStates(), model.getNrOfHiddenStates()});
// now transfer the values
for (int i = 0; i < model.getNrOfHiddenStates(); ++i) {
double value = ip.getQuick(i);
if (value > threshold) {
sparseIp.setQuick(i, value);
}
for (int j = 0; j < model.getNrOfHiddenStates(); ++j) {
value = tr.getQuick(i, j);
if (value > threshold) {
sparseTr.setQuick(i, j, value);
}
}
for (int j = 0; j < model.getNrOfOutputStates(); ++j) {
value = em.getQuick(i, j);