| 1893 | } |
| 1894 | |
| 1895 | CFArray |
| 1896 | solveSystemFq (const CFMatrix& M, const CFArray& L, const Variable& alpha) |
| 1897 | { |
| 1898 | ASSERT (L.size() <= M.rows(), "dimension exceeded"); |
| 1899 | CFMatrix *N; |
| 1900 | N= new CFMatrix (M.rows(), M.columns() + 1); |
| 1901 | |
| 1902 | for (int i= 1; i <= M.rows(); i++) |
| 1903 | for (int j= 1; j <= M.columns(); j++) |
| 1904 | (*N) (i, j)= M (i, j); |
| 1905 | int j= 1; |
| 1906 | for (int i= 0; i < L.size(); i++, j++) |
| 1907 | (*N) (j, M.columns() + 1)= L[i]; |
| 1908 | #ifdef HAVE_FLINT |
| 1909 | // convert mipo |
| 1910 | nmod_poly_t mipo1; |
| 1911 | convertFacCF2nmod_poly_t(mipo1,getMipo(alpha)); |
| 1912 | fq_nmod_ctx_t ctx; |
| 1913 | fq_nmod_ctx_init_modulus(ctx,mipo1,"t"); |
| 1914 | nmod_poly_clear(mipo1); |
| 1915 | // convert matrix |
| 1916 | fq_nmod_mat_t FLINTN; |
| 1917 | convertFacCFMatrix2Fq_nmod_mat_t (FLINTN, ctx, *N); |
| 1918 | // rank |
| 1919 | #if __FLINT_RELEASE >= 30100 |
| 1920 | long rk= fq_nmod_mat_rref (FLINTN,FLINTN,ctx); |
| 1921 | #else |
| 1922 | long rk= fq_nmod_mat_rref (FLINTN,ctx); |
| 1923 | #endif |
| 1924 | #elif defined(HAVE_NTL) |
| 1925 | int p= getCharacteristic (); |
| 1926 | if (fac_NTL_char != p) |
| 1927 | { |
| 1928 | fac_NTL_char= p; |
| 1929 | zz_p::init (p); |
| 1930 | } |
| 1931 | zz_pX NTLMipo= convertFacCF2NTLzzpX (getMipo (alpha)); |
| 1932 | zz_pE::init (NTLMipo); |
| 1933 | mat_zz_pE *NTLN= convertFacCFMatrix2NTLmat_zz_pE(*N); |
| 1934 | long rk= gauss (*NTLN); |
| 1935 | #else |
| 1936 | factoryError("NTL/FLINT missing: solveSystemFq"); |
| 1937 | #endif |
| 1938 | |
| 1939 | delete N; |
| 1940 | if (rk != M.columns()) |
| 1941 | { |
| 1942 | #if defined(HAVE_NTL) && !defined(HAVE_FLINT) |
| 1943 | delete NTLN; |
| 1944 | #endif |
| 1945 | return CFArray(); |
| 1946 | } |
| 1947 | #ifdef HAVE_FLINT |
| 1948 | // convert and clean up |
| 1949 | N=convertFq_nmod_mat_t2FacCFMatrix(FLINTN,ctx,alpha); |
| 1950 | fq_nmod_mat_clear (FLINTN,ctx); |
| 1951 | fq_nmod_ctx_clear(ctx); |
| 1952 | #elif defined(HAVE_NTL) |
no test coverage detected