conversion error related to array index

thorstein torsten.lange at mail.de
Wed Oct 4 09:04:10 UTC 2017


Hi,

I get the following compile error with this function below:
source\mod_data\matrices.d(66,12): Error: cannot implicitly 
convert expression (j) of type ulong to uint

(66,12) is [j] in row[j]

Using uint as type for rows, cols (i.e. the indices) works. Is 
ulong not allowed for array indices? I could not find the 
respective information.

Thanks!


49	private double[][] matrix_uniform(ulong rows, ulong cols, 
double lbound, double ubound, ulong precision)
50	{
51	  double[][] array;
52	  double[] rowT;
53	  auto gen = Random(unpredictableSeed);
54	  auto rndUniform = uniform(lbound, ubound, gen);
55	
56	  foreach(ulong i; 0..cols)
57	  {
58	    rowT ~= 0;
59	  }
60	
61	  foreach(ulong i; 0..rows)
62	  {
63	    foreach(ulong j; 0..cols)
64	    {
65	      rndUniform = uniform(lbound, ubound, gen);
66	      rowT[j] = to!double(rndUniform) / 10^^precision;
67	    }
68	    array ~= rowT.dup;
69	  }
70	    return array;
71	}


More information about the Digitalmars-d-learn mailing list