<commit_before>/* Copyright (C)  LinBox
 * Written by <NAME>
 *
 *
 *
 * ========LICENCE========
 * This file is part of the library LinBox.
 *
  * LinBox is free software: you can redistribute it and/or modify
 * it under the terms of the  GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * ========LICENCE========
 */

#ifndef __LINBOX_signature_H
#define __LINBOX_signature_H
/* Function related to the signature computation of symmetric matrices */

#include "linbox/field/modular.h"
#include "linbox/algorithms/cra-early-multip.h"
#include <fflas-ffpack/ffpack/ffpack.h>
#include "linbox/randiter/random-prime.h"
#include "linbox/matrix/blas-matrix.h"
#include "linbox/algorithms/blas-domain.h"
#include "linbox/solutions/minpoly.h"

namespace LinBox
{

	class Signature {
	public:

		class BLAS_LPM_Method {};
		class Minpoly_Method {};

		template <class Matrix>
		bool isPosDef (const Matrix& M);

		template <class Matrix>
		static bool isPosDef (const Matrix& M, const BLAS_LPM_Method& meth)
		{
			RandomPrimeIterator::setSeed((size_t)time(0));
			size_t n = M. rowdim();
			std::vector<int> P;
			symmetricLU (P, M);
			if (P. size () < n)
				return false;

			typedef typename Matrix::Field::Element Int;
			std::vector<Int> D(n);
			semiD(D, M);

			//std::cout << "All principal minors are: [";
			//for (int i = 0; i < n; ++ i)
			//	std::cout << D[(size_t)i] << ", ";
			//std::cout << "]\n";

			if (allPos(D)) return true;
			else return false;
		}

<commit_msg>test-ispossemidef<commit_after>/* Copyright (C)  LinBox
 * Written by <NAME>
 *
 *
 *
 * ========LICENCE========
 * This file is part of the library LinBox.
 *
  * LinBox is free software: you can redistribute it and/or modify
 * it under the terms of the  GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * ========LICENCE========
 */

#ifndef __LINBOX_signature_H
#define __LINBOX_signature_H
/* Function related to the signature computation of symmetric matrices */

#include "linbox/field/modular.h"
#include "linbox/algorithms/cra-early-multip.h"
#include <fflas-ffpack/ffpack/ffpack.h>
#include "linbox/randiter/random-prime.h"
#include "linbox/matrix/blas-matrix.h"
#include "linbox/algorithms/blas-domain.h"
#include "linbox/solutions/minpoly.h"

namespace LinBox
{

	class Signature {
	public:

		class BLAS_LPM_Method {};
		class Minpoly_Method {};

		template <class Matrix>
		bool isPosDef (const Matrix& M);

		template <class Matrix>
		static bool isPosDef (const Matrix& M, const BLAS_LPM_Method& meth)
		{
			RandomPrimeIterator::setSeed((size_t)time(0));
			size_t n = M. rowdim();
			std::vector<int> P;
			symmetricLU (P, M);
			if (P. size () < n)
				return false;

			typedef typename Matrix::Field::Element Int;
			// std::vector<Int> D(n);
			BlasVector<typename Matrix::Field> D(M.field(),n);
			semiD(D, M);

			//std::cout << "All principal minors are: [";
			//for (int i = 0; i < n; ++ i)
			//	std::cout << D[(size_t)i] << ", ";
			//std::cout << "]\n";

			if (allPos(D)) return true;
			else return false;
		}


{'fraction_non_alphanumeric': 0.12877167973390355, 'fraction_numerical': 0.007127583749109052, 'mean_word_length': 3.8059360730593608, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '349273', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1329, 'n_words': 473}