bytedeco/javacpp

Mat indexer ignores 4th dimension

Open

#701 opened on Aug 7, 2023

View on GitHub
 (2 comments) (0 reactions) (1 assignee)Java (620 forks)batch import
enhancementhelp wanted

Repository metrics

Stars
 (4,279 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

I create a 4dim matrix and then print the elements using createIndexer.toString() code:

	public void testToString4D() {

		Mat mat = mat4d(5, 4, 2, 3);
		System.out.println(mat.createIndexer().toString());
	}

	private Mat mat4d(int s1, int s2, int s3, int s4) {
		int[] data = new int[s1 * s2 * s3 * s4];
		for (int n = 0; n < s1 * s2 * s3 * s4; n++)
			data[n] = n;
		Mat mat = new Mat(data).reshape(1, 4, new int[] { s1, s2, s3, s4 });
		return mat;
	}


It shows

[ (0.0, 3.0), (6.0, 9.0), (12.0, 15.0), (18.0, 21.0)
  (24.0, 27.0), (30.0, 33.0), (36.0, 39.0), (42.0, 45.0)
  (48.0, 51.0), (54.0, 57.0), (60.0, 63.0), (66.0, 69.0)
  (72.0, 75.0), (78.0, 81.0), (84.0, 87.0), (90.0, 93.0)
  (96.0, 99.0), (102.0, 105.0), (108.0, 111.0), (114.0, 117.0) ]

The deepest dimension is completely missing, instead it shows just a single double with what looks like the forst element of the deepest dimension

Contributor guide