Boost logo

Boost Users :

From: Alex Ivanov (lhog_at_[hidden])
Date: 2007-07-03 14:15:18


Hi, Doug!

Thanks a lot for your reply, you've solved my issue.

Best regards, Alex.

"Doug Gregor" <dgregor_at_[hidden]> wrote in message
news:D9C1BCC3-0FD1-490A-BEB6-02A7AEE13AE2_at_osl.iu.edu...
> On Jul 2, 2007, at 6:26 AM, Alex Ivanov wrote:
>> //AFAIK it's impossible to declare array using directive below in
>> runtime:
>> double [xx][xx] D;
>> //Compiler says the same: "C2057: expected constant expression"
>> //even code:
>> double [(const int)xx][(const int)xx] D;
>> //won't work, so the only option left is to make a pointer:
>> double* D = new [xx*xx] ;
>>
>> //but both "floyd_warshall_all_pairs_shortest_paths" and
>> "johnson_all_pairs_shortest_paths" are declared to take a
>> reference, not a
>> pointer, so you'll get multiple compile errors, if you try to
>> compile like
>> below:
>>
>> floyd_warshall_all_pairs_shortest_paths(G, D);
>
> The DistanceMatrix is expected to be subscripted twice, so you would
> need something like:
>
> typedef double* double_array;
>
> double_array* D = new double_array[xx];
> for (int i = 0; i < xx; ++i)
> D[i] = new double [xx];
>
> Or, you could use a vector of vectors:
>
> vector<vector<double> > D(xx, vector<double>(xx));
>
> - Doug


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net