// Path: java_sentence_completion/src/sparse/Pair.java
// public class Pair<A, B> implements Entry<A, B> {
// 	public final A first;
// 	public final B second;
// 
// 	public Pair(A first, B second) {
// 		this.first = first;
// 		this.second = second;
// 	}
// 
// 	public int hashCode() {
// 		int hashFirst = first != null ? first.hashCode() : 0;
// 		int hashSecond = second != null ? second.hashCode() : 0;
// 
// 		return (hashFirst + hashSecond) * hashSecond + hashFirst;
// 	}
// 
// 	public boolean equals(Object other) {
// 		if (other instanceof Pair<?, ?>) {
// 			Pair<?, ?> otherPair = (Pair<?, ?>) other;
// 			return ((this.first == otherPair.first || (this.first != null
// 					&& otherPair.first != null && this.first
// 						.equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null
// 					&& otherPair.second != null && this.second
// 						.equals(otherPair.second))));
// 		}
// 
// 		return false;
// 	}
// 
// 	public String toString() {
// 		return "(" + first + ", " + second + ")";
// 	}
// 
// 	@Override
// 	public A getKey() {
// 		return first;
// 	}
// 
// 	@Override
// 	public B getValue() {
// 		return second;
// 	}
// 
// 	/**
// 	 * Immutable
// 	 * 
// 	 * @throws UnsupportedOperationException
// 	 *             always
// 	 */
// 	@Override
// 	public B setValue(B value) throws UnsupportedOperationException {
// 		throw new UnsupportedOperationException("Immutable");
// 	}
// 
// }
// 
// Path: java_sentence_completion/src/sparse/PairOfInts.java
// public class PairOfInts implements Comparable<PairOfInts> {
// 	public final int first;
// 	public final int second;
// 
// 	public PairOfInts(int first, int second) {
// 		this.first = first;
// 		this.second = second;
// 	}
// 	
// 	public PairOfInts(Entry<Integer, Integer> entry){
// 		first = entry.getKey();
// 		second  = entry.getValue();
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		final int prime = 31;
// 		int result = 1;
// 		result = prime * result + first;
// 		result = prime * result + second;
// 		return result;
// 	}
// 
// 	public String toString() {
// 		return "(" + first + ", " + second + ")";
// 	}
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if (this == obj) {
// 			return true;
// 		}
// 		if (obj == null) {
// 			return false;
// 		}
// 		if (getClass() != obj.getClass()) {
// 			return false;
// 		}
// 
// 		PairOfInts other = (PairOfInts) obj;
// 		return first == other.first && second == other.second;
// 	}
// 
// 	@Override
// 	public int compareTo(PairOfInts o) {
// 		int first_diff = first - o.first;
// 		if (first_diff != 0) {
// 			return first_diff;
// 		}
// 		return second - o.second;
// 	}
// 
// 	/**
// 	 * put the second number in first position, and the first in second
// 	 * <p>
// 	 * Matthew 20:16 : "So the last will be first, and the first will be last."
// 	 * </p>
// 	 * 
// 	 * @return a new object with the inverted fields
// 	 */
// 	public PairOfInts reverse() {
// 		return new PairOfInts(second, first);
// 	}
// }


import java.util.Arrays;
import java.util.HashSet;
import java.util.TreeMap;
import java.util.Map.Entry;
import java.util.Set;
import sparse.Pair;
import sparse.PairOfInts;
/**
 * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert
 * 
 * Confabulation_Symbolic is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Confabulation_Symbolic is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Confabulation_Symbolic.  If not, see <http://www.gnu.org/licenses/>.
 */

//
// Auto-generated file from float_/CSC2Dfloat.java
//
package sparse.int_;



/**
 * Compressed sparse column matrix
 * 
 * @author bernard and cedric
 * 
 */
public class CSC2Dint extends Matrix2Dint {

	protected final int[] A;
	protected final int[] IA;
	protected final int[] JA;

	public CSC2Dint(Matrix2Dint m) {
		super(m.nlines, m.ncols);
		int nnz = m.nnz();
		A = new int[nnz];
		IA = new int[ncols + 1];
		JA = new int[nnz];

		// get the nz elements ordered by column
// Path: java_sentence_completion/src/sparse/Pair.java
// public class Pair<A, B> implements Entry<A, B> {
// 	public final A first;
// 	public final B second;
// 
// 	public Pair(A first, B second) {
// 		this.first = first;
// 		this.second = second;
// 	}
// 
// 	public int hashCode() {
// 		int hashFirst = first != null ? first.hashCode() : 0;
// 		int hashSecond = second != null ? second.hashCode() : 0;
// 
// 		return (hashFirst + hashSecond) * hashSecond + hashFirst;
// 	}
// 
// 	public boolean equals(Object other) {
// 		if (other instanceof Pair<?, ?>) {
// 			Pair<?, ?> otherPair = (Pair<?, ?>) other;
// 			return ((this.first == otherPair.first || (this.first != null
// 					&& otherPair.first != null && this.first
// 						.equals(otherPair.first))) && (this.second == otherPair.second || (this.second != null
// 					&& otherPair.second != null && this.second
// 						.equals(otherPair.second))));
// 		}
// 
// 		return false;
// 	}
// 
// 	public String toString() {
// 		return "(" + first + ", " + second + ")";
// 	}
// 
// 	@Override
// 	public A getKey() {
// 		return first;
// 	}
// 
// 	@Override
// 	public B getValue() {
// 		return second;
// 	}
// 
// 	/**
// 	 * Immutable
// 	 * 
// 	 * @throws UnsupportedOperationException
// 	 *             always
// 	 */
// 	@Override
// 	public B setValue(B value) throws UnsupportedOperationException {
// 		throw new UnsupportedOperationException("Immutable");
// 	}
// 
// }
// 
// Path: java_sentence_completion/src/sparse/PairOfInts.java
// public class PairOfInts implements Comparable<PairOfInts> {
// 	public final int first;
// 	public final int second;
// 
// 	public PairOfInts(int first, int second) {
// 		this.first = first;
// 		this.second = second;
// 	}
// 	
// 	public PairOfInts(Entry<Integer, Integer> entry){
// 		first = entry.getKey();
// 		second  = entry.getValue();
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		final int prime = 31;
// 		int result = 1;
// 		result = prime * result + first;
// 		result = prime * result + second;
// 		return result;
// 	}
// 
// 	public String toString() {
// 		return "(" + first + ", " + second + ")";
// 	}
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if (this == obj) {
// 			return true;
// 		}
// 		if (obj == null) {
// 			return false;
// 		}
// 		if (getClass() != obj.getClass()) {
// 			return false;
// 		}
// 
// 		PairOfInts other = (PairOfInts) obj;
// 		return first == other.first && second == other.second;
// 	}
// 
// 	@Override
// 	public int compareTo(PairOfInts o) {
// 		int first_diff = first - o.first;
// 		if (first_diff != 0) {
// 			return first_diff;
// 		}
// 		return second - o.second;
// 	}
// 
// 	/**
// 	 * put the second number in first position, and the first in second
// 	 * <p>
// 	 * Matthew 20:16 : "So the last will be first, and the first will be last."
// 	 * </p>
// 	 * 
// 	 * @return a new object with the inverted fields
// 	 */
// 	public PairOfInts reverse() {
// 		return new PairOfInts(second, first);
// 	}
// }


// Path: java_sentence_completion/src/sparse/int_/CSC2Dint.java
import java.util.Arrays;
import java.util.HashSet;
import java.util.TreeMap;
import java.util.Map.Entry;
import java.util.Set;
import sparse.Pair;
import sparse.PairOfInts;

/**
 * Copyright 2011-2012 Bernard Paulus and Cédric Snauwaert
 * 
 * Confabulation_Symbolic is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Confabulation_Symbolic is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Confabulation_Symbolic.  If not, see <http://www.gnu.org/licenses/>.
 */

//
// Auto-generated file from float_/CSC2Dfloat.java
//
package sparse.int_;



/**
 * Compressed sparse column matrix
 * 
 * @author bernard and cedric
 * 
 */
public class CSC2Dint extends Matrix2Dint {

	protected final int[] A;
	protected final int[] IA;
	protected final int[] JA;

	public CSC2Dint(Matrix2Dint m) {
		super(m.nlines, m.ncols);
		int nnz = m.nnz();
		A = new int[nnz];
		IA = new int[ncols + 1];
		JA = new int[nnz];

		// get the nz elements ordered by column
		TreeMap<PairOfInts, Integer> ordered_m = new TreeMap<PairOfInts, Integer>();