Skip to content
Snippets Groups Projects
Commit 7a4f213c authored by Cyrille Valladeau's avatar Cyrille Valladeau
Browse files

ENH: Correct vector access, exception if the size of the vector is null

parent 5c3d875a
Branches
Tags
No related merge requests found
......@@ -33,22 +33,29 @@ typename VariableLengthVectorConverter< std::vector<std::vector<TInternalInputTy
VariableLengthVectorConverter< std::vector<std::vector<TInternalInputType> >, TPrecisionType>
::Convert(InputType input)
{
unsigned int p, q, rsltIdx = 0;
unsigned int p, q, count, rsltIdx = 0;
OutputType result;
p = input.size();
q = input.at(0).size();
result.SetSize(p*q);
for (unsigned int l=0; l<p; l++)
{
count+=input.at(l).size();
}
result.SetSize(count);
for (unsigned int i=0; i<p; i++)
{
for (unsigned int j=0; j<q; j++)
{
result[rsltIdx] = static_cast<OutputPrecisionType>(input.at(i).at(j));
rsltIdx ++;
}
q = input.at(i).size();
for (unsigned int j=0; j<q; j++)
{
result[rsltIdx] = static_cast<OutputPrecisionType>(input.at(i).at(j));
rsltIdx ++;
}
}
return result;
}
......@@ -61,16 +68,21 @@ VariableLengthVectorConverter< std::vector<std::vector<std::complex<TInternalInp
TPrecisionType>
::Convert(InputType input)
{
unsigned int p, q, rsltIdx = 0;
unsigned int p, q, count, rsltIdx = 0;
OutputType result;
p = input.size();
q = input.at(0).size();
result.SetSize(p*q*2);
for (unsigned int l=0; l<p; l++)
{
count+=input.at(l).size();
}
result.SetSize(count*2);
for (unsigned int i=0; i<p; i++)
{
q = input.at(i).size();
for (unsigned int j=0; j<q; j++)
{
result[rsltIdx] = static_cast<OutputPrecisionType>(input.at(i).at(j).real());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment