int matRows = A.trim(1).getRows(); int matCols = A.trim(1).getCols();
int matRows = A.getRows(); int matCols = A.getCols();
    private LinearCost calculateCost() {	// add up multiplies and adds that are necessary for each column of the matrix. 	int muls = 0;	int adds = 0;	int matRows = A.trim(1).getRows();	int matCols = A.trim(1).getCols();		for (int col=0; col<matCols; col++) {	    // counters for the colums (# muls, adds)	    int rowAdds = 0;	    int rowMuls =  0;	    for (int row=0; row<matRows; row++) {		ComplexNumber currentElement = A.getElement(row,col);		if (!currentElement.isReal()) {		    throw new RuntimeException("Non real matrix elements are not supported in cost .");		}		// flags on whether or not to increment the counters		boolean incAdd = true;		boolean incMul = true;		// if it is zero, no add or mult is necessary		if (currentElement.equals(ComplexNumber.ZERO)) {		    incAdd = false;		    incMul = false;		// if one, no need to do a multiplication.		} else if (currentElement.equals(ComplexNumber.ONE)) {		    incMul = false;		}		// now, increment if our increment flags are set.		if (incAdd) {rowAdds++;}		if (incMul) {rowMuls++;}	    }	    // now, add in the contribution from the constant vector	    ComplexNumber currentElement = b.getElement(0,col);	    if (!currentElement.isReal()) {		throw new RuntimeException("Non real vector elements are not supported in cost .");	    }	    // nothing for zero, inc add for one, and inc both for anything else.	    if (currentElement.equals(ComplexNumber.ZERO)) {	    } else if (currentElement.equals(ComplexNumber.ONE)) {		rowAdds++;	    } else {		rowAdds++;		rowMuls++;	    }	    // basically, we need one less add per row because adds take two operands	    // however, we don't want to blindly subtract one, because that might give	    // us a negative number	    if (rowAdds > 0) {rowAdds--;}	    // stick row counters onto overall counters	    muls += rowMuls;	    adds += rowAdds;	}	return new LinearCost(muls, adds, matRows, matCols, popCount);    }	    