Discriminant_PatternList_Categories.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Discriminant_PatternList_Categories.cpp
  2. *
  3. * Copyright (C) 2004-2011, 2015 David Weenink
  4. *
  5. * This code is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This code is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /*
  19. djmw 20040422 Initial version
  20. */
  21. #include "Discriminant_PatternList_Categories.h"
  22. #include "TableOfReal.h"
  23. #include "Matrix_Categories.h"
  24. autoDiscriminant PatternList_Categories_to_Discriminant (PatternList me, Categories thee) {
  25. try {
  26. autoTableOfReal t = Matrix_Categories_to_TableOfReal (me, thee);
  27. autoDiscriminant him = TableOfReal_to_Discriminant (t.get());
  28. return him;
  29. } catch (MelderError) {
  30. Melder_throw (U"Discriminant not created from PatternList & Categories.");
  31. }
  32. }
  33. autoCategories Discriminant_PatternList_to_Categories (Discriminant me, PatternList thee, int poolCovarianceMatrices, int useAprioriProbabilities) {
  34. try {
  35. autoTableOfReal t = Matrix_to_TableOfReal (thee);
  36. autoClassificationTable ct = Discriminant_TableOfReal_to_ClassificationTable (me, t.get(), poolCovarianceMatrices, useAprioriProbabilities);
  37. autoCategories him = ClassificationTable_to_Categories_maximumProbability (ct.get());
  38. return him;
  39. } catch (MelderError) {
  40. Melder_throw (U"Categories not created from PatternList & Discriminant.");
  41. }
  42. }
  43. /* End of file Discriminant_PatternList_Categories.cpp */