nagyistoce / visual-rbm

Automatically exported from code.google.com/p/visual-rbm
0 stars 0 forks source link

Source code ReadRow from IDX.hpp #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Function ReadRow does not read recently written data with AddRow.
In variable rbuffer I get some same high number, not contents of wbuffer.
The contents of actual .idx file are correct.

<code>
bool res1, res2;
uint32_t pCol=120;
uint32_t pRow=2;//2977;
uint32_t col=0;
uint32_t row=0, i=0;
float* rbuffer = new float[pCol];
float* wbuffer = new float[pCol];
float* tbuffer = new float[pCol];

IDX* in2_data = IDX::Create("D75IN_tmp.idx", LittleEndian, Single, pCol);

for (i=0; i<pCol; i++)
{
   wbuffer[i]=0.01*i;
   //printf("[%3i]=%1.5f, ", i, wbuffer[i]);
}

for (row=0; row<pRow; row++) //in2_data->GetRowCount()
{   
   res1=in2_data->AddRow(wbuffer);
   res2=in2_data->ReadRow(row, rbuffer);
   if (res1!=true || res2!=true) printf("Error res1 res2 !!! \n");

   printf("in2_data row=%i \n", row);
   for (col=0; col < in2_data->GetRowLength(); col++) 
      printf("[%3i][%3i]=%1.5f, ", row, col, rbuffer[col]);

   //printf("row=[%i] res1=%i; res2=%i; ", row, res1, res2);
}

</code>

Using Windows7 and MS VS Express 2012.

Original issue reported on code.google.com by klu...@jabster.pl on 23 Jan 2014 at 2:24

GoogleCodeExporter commented 9 years ago
This is as designed (the internal FILE* is opened for writing only when 
IDX::Create is used versus IDX::Load).  I'll fix this tonight when I get off of 
work.  I'm almost certain there isn't any reason why I can't open for reading 
and writing, but I'll need to take a closer look.  If that's not the case then 
I'll fix ReadRow so it returns false when attempting to read from a write only 
IDX.  

best,
-Richard

Original comment by pospes...@gmail.com on 23 Jan 2014 at 3:54

GoogleCodeExporter commented 9 years ago
Fixed in CL#251

If you aren't already, you should use the IDX.hpp found in the OMLT project:

http://code.google.com/p/visual-rbm/source/browse/trunk/source/OMLT/OMLT/include
/IDX.hpp

It should be a drop in replacement, it just lives in the OMLT namespace now.

best,
-Richard

Original comment by pospes...@gmail.com on 24 Jan 2014 at 3:21

GoogleCodeExporter commented 9 years ago
Thanks, it works now

--
Krzysztof

Original comment by klu...@jabster.pl on 24 Jan 2014 at 1:51