| 444 | } |
| 445 | |
| 446 | cMatrix * cDataReader::getMatrix(long vIdx, long length, int special, int privateVec) // vIdx: start index of matrix (absolute) |
| 447 | { |
| 448 | // XXX TODO: get multiple frames, concat them |
| 449 | // PROBLEM::: only return success, if all frames were read successfully |
| 450 | // if not all frames were read successfully, UNDO changes to write/read counters!! |
| 451 | // THUS::=> use a checkRead() function to see if data is available!! |
| 452 | |
| 453 | long i,n; |
| 454 | int r=1; |
| 455 | cMatrix *my_m = NULL; |
| 456 | if (!privateVec) my_m=m; |
| 457 | |
| 458 | if (nLevels > 1) { |
| 459 | |
| 460 | for (i=0; i<nLevels; i++) { |
| 461 | r &= dm->checkRead(level[i],vIdx,special,rdId[i],length); |
| 462 | } |
| 463 | if (r) { |
| 464 | if (my_m!=NULL) { |
| 465 | if (length != my_m->nT) { |
| 466 | delete my_m; |
| 467 | my_m=NULL; |
| 468 | } |
| 469 | } |
| 470 | if (my_m == NULL) my_m = new cMatrix(myLcfg->N,length); |
| 471 | |
| 472 | int fmetaUpdate = 0; |
| 473 | if (myfmeta == NULL) { |
| 474 | fmetaUpdate = 1; |
| 475 | myfmeta = new FrameMetaInfo(); |
| 476 | if (myfmeta == NULL) OUT_OF_MEMORY; |
| 477 | myfmeta->N = myLcfg->Nf; // assign number of fields (total) |
| 478 | myfmeta->field = (FieldMetaInfo *)calloc(1,sizeof(FieldMetaInfo)*(myLcfg->Nf)); |
| 479 | myLcfg->fmeta = myfmeta; |
| 480 | } |
| 481 | |
| 482 | FLOAT_DMEM*df = my_m->data; |
| 483 | long N = myLcfg->N; |
| 484 | long f=0; |
| 485 | long minlen = length; |
| 486 | for (i=0; i<nLevels; i++) { |
| 487 | |
| 488 | cMatrix *m2 = dm->getMatrix(level[i],vIdx,vIdx+length, special, rdId[i]); |
| 489 | if (m2 != NULL) { |
| 490 | if (m2->nT < minlen) { minlen = m2->nT; } |
| 491 | // copy data from f2 into V at the correct position |
| 492 | for (n=0; n<minlen /*length*/; n++) |
| 493 | memcpy( df+(N*n) , m2->data + n*(m2->N), m2->N*sizeof(FLOAT_DMEM) ); |
| 494 | df += m2->N; |
| 495 | |
| 496 | if (i==0) my_m->copyTimeMeta(m2->tmeta); // TODO: change this for asynchronous levels... |
| 497 | |
| 498 | //concat fmeta!! |
| 499 | if (fmetaUpdate) { |
| 500 | int j; |
| 501 | for (j=0; j<m2->fmeta->N; j++) { |
| 502 | // now copy each field from corresponding frame |
| 503 | myfmeta->field[f++].copyFrom(m2->fmeta->field+j); |