Last active
August 29, 2015 14:08
-
-
Save jmbr/3c0104d5665667686d6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Example: spy("foobar.ppm", A); | |
*/ | |
int spy(std::string const& ppmfile, arma::mat const& M) { | |
ofstream ofs(ppmfile); | |
if (!ofs.is_open()) | |
return -1; | |
ofs << "P3\n" << M.n_rows << " " << M.n_cols << "\n1\n"; | |
for (unsigned i = 0; i < M.n_rows; ++i) { | |
for (unsigned j = 0; j < M.n_cols; ++j) { | |
for (unsigned k = 0; k < 3; ++k) | |
ofs << (M(i, j) == 0) << " "; | |
ofs << " "; | |
} | |
ofs << "\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment