2016-06-29 17 views
0

Ich traf ein sehr seltsames Problem. Die Zufallsfunktion von armadillo funktioniert nicht. Es gibt nur Nullen zurück. Zum Beispiel:Armadillo Randu funktioniert nicht

#include <iostream> 
#include <armadillo> 

using namespace std; 
using namespace arma; 

int 
main(int argc, char **argv) { 
    // 2D field of matrices; 3D fields are also supported 
    field<mat> F(4, 2); 

    for (uword col = 0; col < F.n_cols; ++col) 
     for (uword row = 0; row < F.n_rows; ++row) { 
      F(row, col) = randu <mat> (2, 3); // each element in field<mat> is a matrix 
     } 

    F.print("F:"); 

    return 0; 
} 

Die Ausgabe lautet:

F:

[field column 0] 
     0  0  0 
     0  0  0 

     0  0  0 
     0  0  0 

     0  0  0 
     0  0  0 

     0  0  0 
     0  0  0 


[field column 1] 
     0  0  0 
     0  0  0 

     0  0  0 
     0  0  0 

     0  0  0 
     0  0  0 

     0  0  0 
     0  0  0 

Jede Idee, warum dies geschieht?

+1

Versuchte Ihren Code und es funktionierte gut (mit Armadillo 6.700.4). Hast du versucht, einen sauberen Build zu machen? –

+0

@ClaesRolen Danke für Ihren Kommentar. Ja das ist so komisch. Was meinst du mit "make a clean build"? – spacegoing

+1

Entfernen Sie alle generierten O-Dateien und kompilieren Sie sie erneut, um sicherzustellen, dass der Build auf der neuesten Quelldatei basiert. –

Antwort

0

Ich hatte ein ähnliches Problem (unter Windows). Ich habe die folgende Zeile in config.hpp

auskommentiert und danach die Randu/Randn usw. Befehle richtig funktioniert.