Java API By Example, From Geeks To Geeks.

# Java > Open Source Codes > org > jscience > mathematics > vectors > SparseMatrix

 1 /*2  * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.3  * Copyright (C) 2006 - JScience (http://jscience.org/)4  * All rights reserved.5  * 6  * Permission to use, copy, modify, and distribute this software is7  * freely granted, provided that this notice is preserved.8  */9 package org.jscience.mathematics.vectors;10 11 import java.util.Iterator ;12 import java.util.List ;13 14 import javolution.lang.MathLib;15 import javolution.util.FastComparator;16 import javolution.util.FastMap;17 import javolution.util.FastTable;18 import javolution.util.Index;19 20 import org.jscience.mathematics.structures.Field;21 22 /**23  *

This class represents a matrix made of {@link SparseVector sparse24  * vectors} (as rows). To create a sparse matrix made of column vectors the 25  * {@link #transpose} method can be used. 26  * For example:[code]27  * SparseVector column0 = SparseVector.valueOf(...);28  * SparseVector column1 = SparseVector.valueOf(...);29  * SparseMatrix M = SparseMatrix.valueOf(column0, column1).transpose();30  * [/code]

31  *

As for any concrete {@link org.jscience.mathematics.structures.Structure32  * structure}, this class is declared final (otherwise most33  * operations would have to be overridden to return the appropriate type).34  * Specialized dense matrix should sub-class {@link Matrix} directly.35  * For example:[code]36  * // Extension through composition.37  * final class BandMatrix > extends Matrix {38  * private SparseMatrix _value;39  * ...40  * public BandMatrix opposite() { // Returns the right type.41  * return BandMatrix.valueOf(_value.opposite());42  * }43  * ...44  * }[/code]45  *