+ n = accumulate( columntotal.begin(), columntotal.end(), 0 );
+
+ //============================================================
+
+ //generate a probability matrix. Only do this once.
+ float start = 0.0;
+
+ if (matrix == "sim1") {
+ for(int i=0;i<nrows;i++) {
+ for(int j=0;j<ncols;j++) {
+ probabilityMatrix[ncols * i + j] = start + 1/double(nrows*ncols);
+ start = start + 1/double(nrows*ncols);
+ }
+ }
+ }
+ else if (matrix == "sim2") {
+ for(int i=0;i<nrows;i++) {
+ start = 0.0;
+ for(int j=0;j<ncols;j++) {
+ probabilityMatrix[ncols * i + j] = start + 1/double(ncols);
+ start = start + 1/double(ncols);
+ }
+ }
+ }
+
+ else if (matrix == "sim3") {
+ for(int j=0;j<ncols;j++) {
+ start = 0.0;
+ for(int i=0;i<nrows;i++) {
+ probabilityMatrix[ncols * i + j] = start + 1/double(nrows);
+ start = start + 1/double(nrows);
+ }
+ }
+ }
+
+ else if (matrix == "sim4") {
+ for(int i=0;i<nrows;i++) {
+ start = 0.0;
+ for(int j=0;j<ncols;j++) {
+ probabilityMatrix[ncols * i + j] = start + columntotal[j]/double(n);
+ start = start + columntotal[j]/double(n);
+ }
+ }
+ }
+
+ else if (matrix == "sim5") {
+ for(int j=0;j<ncols;j++) {
+ start = 0.0;
+ for(int i=0;i<nrows;i++) {
+ probabilityMatrix[ncols * i + j] = start + rowtotal[i]/double(n);
+ start = start + rowtotal[i]/double(n);
+ }
+ }
+ }
+
+ else if (matrix == "sim6") {
+ for(int i=0;i<nrows;i++) {
+ for(int j=0;j<ncols;j++) {
+ probabilityMatrix[ncols * i + j] = start + columntotal[j]/double(n*nrows);
+ start = start + columntotal[j]/double(n*nrows);
+ }
+ }
+ }
+
+
+ else if (matrix == "sim7") {
+ for(int i=0;i<nrows;i++) {
+ for(int j=0;j<ncols;j++) {
+ probabilityMatrix[ncols * i + j] = start + rowtotal[i]/double(n*ncols);
+ start = start + rowtotal[i]/double(n*ncols);
+ }
+ }
+ }
+
+ else if (matrix == "sim8") {
+ for(int i=0;i<nrows;i++) {
+ for(int j=0;j<ncols;j++) {
+ probabilityMatrix[ncols * i + j] = start + (rowtotal[i]*columntotal[j])/double(n*n);
+ start = start + (rowtotal[i]*columntotal[j])/double(n*n);
+ }
+ }
+ }
+
+ else {
+ if(sim != 9) {
+ m->mothurOut("[ERROR]: No model selected! \n");
+ m->control_pressed = true;
+ }
+ }
+