bigladder / btwxt

N-dimensional grid interpolation library
BSD 3-Clause "New" or "Revised" License
15 stars 8 forks source link

More arrays, less vectors? #15

Open chipbarnaby opened 3 years ago

chipbarnaby commented 3 years ago

There may be ways to use arrays as opposed to vectors. Reduced memory management overhead on caller side?

nealkruis commented 3 years ago

My understanding is that arrays need to know their length at compile time. I'm not sure we can know that for any of our vectors.

chipbarnaby commented 3 years ago

Arrays can be allocated on the heap at run time. They just cannot change size once allocated.

nealkruis commented 3 years ago

@tanaya-bigladder thoughts on this?

tanaya-mankad commented 2 years ago

std::array<T,N> is a template, so the element type and size have to be known at compile time. I'd imagine anything that can be expressed as a constexpr is allowed for the size template parameter, but we couldn't, say, read in the number of axes from an RS and then initialize a std::array<Axes,N> at that point in the runtime code. The only STL container I've ever used that way is a vector.

nealkruis commented 2 years ago

@chipbarnaby are you suggesting that we use C-style arrays?

tanaya-mankad commented 2 years ago

Same problem, though. You can't initialize a C array with a non-const size.