Advertisement
lordcobisco

Untitled

Jan 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.68 KB | None | 0 0
  1. for (uint16_t i = 0; i < quantityOfRegions; ++i) // Percorre todas as matrizes de restrições para  verificar em qual região os estados estão localizados.
  2.     {
  3.         // std::cout << "A matriz de restricoes: \n"<< this->Restrictions[i] << std::endl;
  4.         // std::cout << "A matriz de pontos: \n"<< point << std::endl;
  5.  
  6.         // LinAlg::Matrix<Type> H = (this->Restrictions[i]); // se todos os elementos desse vetor forem menores que uma tolerância (podem ser negativos), os estados pertencerão ao conjunto de restrições. Isso se aplica a linha 23 também (função any)
  7.  
  8. //        std::cout << "Resultado de H: \n"<< point << std::endl;
  9.         LinAlg::Matrix<Type> H(this->Restrictions[i].getNumberOfRows(),1);
  10.  
  11.         for(unsigned k = 0; k < this->Restrictions[i].getNumberOfRows(); k++)
  12.             for(unsigned col = 0; col < point.getNumberOfColumns(); col++)
  13.             {
  14.                 Type temp = 0.0;
  15.                 for(unsigned j = 0; j < this->Restrictions[i].getNumberOfColumns(); j++)
  16.                     temp += this->Restrictions[i](k,j) * point(j,col);
  17.                 H(k,col) = temp;
  18.             }
  19.             // if(i == 0 ){
  20.             //   std::cout << "H =  "<< H << std::endl << "Point = " << point << std::endl;  
  21.             //   std::cout << "A matriz de restricoes: \n"<< this->Restrictions[i] << std::endl;
  22.             // }
  23.         if(!any(H))//Verifica se algum estado esta fora das restrições.
  24.         {
  25.             this->inWitchRegion = i;//sinaliza qual a região a qual os estados pertencem
  26. //            std::cout << "Controle na regiao: "<< i+1 << std::endl;
  27.             return true; // Sinaliza que encontrou uma região.
  28.         }
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement