public static SparseVector[] transpose(SparseVector[] input) {
        int firstDimension = input.length;
        int secondDimension = input[0].size;

        ArrayList<ArrayList<Integer>> indices = new ArrayList<>();
        ArrayList<ArrayList<Double>> values = new ArrayList<>();

        for (int i = 0; i < secondDimension; i++) {
            indices.add(new ArrayList<>());
            values.add(new ArrayList<>());
        }

        for (int i = 0; i < firstDimension; i++) {
            for (VectorTuple f : input[i]) {
                indices.get(f.index).add(i);
                values.get(f.index).add(f.value);
            }
        }

        SparseVector[] output = new SparseVector[secondDimension];

        for (int i = 0; i < secondDimension; i++) {
            output[i] = new SparseVector(firstDimension,Util.toPrimitiveInt(indices.get(i)),Util.toPrimitiveDouble(values.get(i)));
        }

        return output;
    }
@Test
    public void testTranspose() {
        SparseVector[] input = new SparseVector[3];
        input[0] = generateVectorA();
        input[1] = generateVectorB();
        input[2] = generateVectorC();

        SparseVector[] transpose = SparseVector.transpose(input);
        SparseVector[] inputPrime = SparseVector.transpose(transpose);

        assertEquals(input.length,inputPrime.length);

        for (int i = 0; i < input.length; i++) {
            assertEquals(input[i],inputPrime[i]);
        }
    }