@SuppressWarnings("unchecked")
    public static <T extends Number> ArrayList<ArrayList<T>> mulSparseMatrixWithArrayMatrix(SparseMatrix a, ArrayList<ArrayList<Double>> b,
	    Class<T> type) {
	try {
	    
	    ArrayList<ArrayList<T>> result = new ArrayList<ArrayList<T>>();
	    if (a == null || b == null) {
		throw new NullPointerException();
	    }
	    
	    ArrayList<ArrayList<Integer>> rowIndexes = getClone(a.getRowIndexes(), Integer.class);
	    ArrayList<Double> values = VectorOpUtils.getClone(a.getValues(), Double.class);
	    Collections.fill(values, 0.0);
	    
	    int rows = a.getSize();
	    int cols = b.get(0).size();
	    Logger.getLogger(MatrixOpUtils.class.getSimpleName()).info("sorted indexes");
	    
	    for (int i = 0; i < rows; i++) {
		ArrayList<Integer> row = rowIndexes.get(i);
		if (row != null) {
		    ArrayList<T> rowToAdd = new ArrayList<>();
		    for (int col = 0; col < cols; col++) {
			T elem = ElementOpUtils.getNeutralSumElem(type);
			elem = ElementOpUtils.sum(elem, ElementOpUtils.mul((T) a.getElement(i, i), (T) b.get(i).get(col), type), type);
			for (Integer k : row) {
			    elem = ElementOpUtils.sum(elem, ElementOpUtils.mul((T) a.getElement(i, k), (T) b.get(k).get(col), type), type);
			}
			rowToAdd.add(elem);
		    }
		    result.add(rowToAdd);
		}
	    }
	    return result;
	} catch (NullPointerException e) {
	    Logger.getGlobal().log(Level.SEVERE, "cannot multiply null matrixes");
	    e.printStackTrace();
	    return null;
	} catch (IndexOutOfBoundsException e) {
	    Logger.getGlobal().log(Level.SEVERE, "check your indexes when multiplying matrixes");
	    e.printStackTrace();
	    return null;
	}
    }