Radiroot package in GAP generating errors - package

When I run the following commands
g := UnivariatePolynomial(Rationals, [12,-5,0,0,0,1]);
RootsOfPolynomialAsRadicals(g);
I get this error
*** too many arguments: ...;,nf=nfinit([f,nfbasis(f,1)]);fac=lift(nffact
*** ^--------------------
*** at top-level: for(i=1,#fac[,1],for(j=1,fac[i,2
*** ^--------------------
*** incorrect type in _[,_] OCcompoC [not a matrix] (t_POL).
Error, List Element: <list>[1] must have an assigned value in
faktoren[1] := lcoeff * faktoren[1]; at /proc/cygdrive/C/gap486/pkg/Alnuth-3.0.0/gap/factors.gi:99 called from
FactorsPolynomialPari( AlgExtEmbeddedPol( H, poly )
) at /proc/cygdrive/C/gap486/pkg/Alnuth-3.0.0/gap/factors.gi:51 called from
FactorsPolynomialAlgExt( erw.H, poly ) at /proc/cygdrive/C/gap486/pkg/radiroot/lib/SplittField.gi:237 called from
RR_Zerfaellungskoerper( poly, rec(
roots := [ ],
degs := [ ],
coeffs := [ ],
K := FieldByMatrices( [ [ [ 1 ] ] ] ),
H := Rationals ) ) at /proc/cygdrive/C/gap486/pkg/radiroot/lib/Radicals.gi:293 called from
CallFuncList( RootsOfPolynomialAsRadicalsNC, arg
) at /proc/cygdrive/C/gap486/pkg/radiroot/lib/Radicals.gi:253 called from
<function "RootsOfPolynomialAsRadicals">( <arguments> )
called from read-eval loop at line 2 of *stdin*
you can 'return;' after assigning a value
I am using GAP 4.8.6 on windows 10, installed from the windows installer on the GAP downloads page, and PARI/GP 2.9.1 64 bit (stable installer). I've also tried manually downloading and using the latest versions of Alnuth and Radiroot but I'm still getting the same error. Does anyone know how to fix this?

This now works in GAP 4.11.0, with Alnuth 3.1.2, RadiRoot 2.8 and Pari/GP 2.9.3, under macOS:
g := UnivariatePolynomial(Rationals, [12,-5,0,0,0,1]);
RootsOfPolynomialAsRadicals(g);
starts an xdvi viewer which displays the result. It's hard to read as an image, so I am providing the LaTeX source for it, which may be more useful:
\documentclass[fleqn]{article}
\setlength{\paperwidth}{84cm}
\setlength{\textwidth}{80cm}
\setlength{\paperheight}{59.5cm}
\setlength{\textheight}{57cm}
\begin{document}
\noindent
An expression by radicals for the roots of the polynomial $x^{5} - 5x + 12$ with the $n$-th root of unity $\zeta_n$ and
\\
$\omega_1 = \sqrt[2]{ - 10}$,\\
$\omega_2 = \sqrt[5]{\left( - \frac{421}{5}\zeta_{5} - \frac{449}{5}\zeta_{5}^{2} - \frac{49}{5}\zeta_{5}^{3} + \frac{229}{5}\zeta_{5}^{4}\right) + \left( - \frac{168}{25}\zeta_{5} - \frac{849}{25}\zeta_{5}^{2} - \frac{1101}{25}\zeta_{5}^{3} - \frac{582}{25}\zeta_{5}^{4}\right)\omega_1}$,\\
\\
is:
\\
\noindent
$\left( - \frac{2}{11}\zeta_{5} - \frac{1}{11}\zeta_{5}^{2} + \frac{4}{11}\zeta_{5}^{3} - \frac{4}{11}\zeta_{5}^{4}\right)\omega_2 + \left( - \frac{42}{121}\zeta_{5} + \frac{34}{121}\zeta_{5}^{2} - \frac{92}{121}\zeta_{5}^{3} + \frac{15}{121}\zeta_{5}^{4}\right)\omega_2^2 + \left(\frac{91}{605}\zeta_{5} + \frac{7}{605}\zeta_{5}^{2} + \frac{38}{605}\zeta_{5}^{3} + \frac{149}{605}\zeta_{5}^{4}\right)\omega_1\omega_2^2 + \left(\frac{175}{1331}\zeta_{5} + \frac{302}{1331}\zeta_{5}^{2} + \frac{706}{1331}\zeta_{5}^{3} + \frac{482}{1331}\zeta_{5}^{4}\right)\omega_2^3 + \left(\frac{255}{1331}\zeta_{5} + \frac{364}{1331}\zeta_{5}^{2} + \frac{40}{1331}\zeta_{5}^{3} + \frac{246}{1331}\zeta_{5}^{4}\right)\omega_1\omega_2^3 + \left( - \frac{11480}{14641}\zeta_{5} + \frac{420}{14641}\zeta_{5}^{2} + \frac{7725}{14641}\zeta_{5}^{3} - \frac{740}{14641}\zeta_{5}^{4}\right)\omega_2^4 + \left(\frac{786}{14641}\zeta_{5} + \frac{6399}{14641}\zeta_{5}^{2} + \frac{45}{14641}\zeta_{5}^{3} + \frac{1275}{14641}\zeta_{5}^{4}\right)\omega_1\omega_2^4$
\end{document}
It's difficult to say what was the original problem, there were many changes in both packages, which are now hosted on GitHub - the source code repositories are https://github.com/gap-packages/radiroot and https://github.com/gap-packages/alnuth.

Related

CUDA.jl: ERROR: LoadError: MethodError: no method matching typeof(fillpixel!)(::CuDeviceMatrix{RGB{Float32}, 1})

I had made a very minimal ray tracer in Julia, and was in the process of implementing a faster version that uses CUDA. The full code is too extensive to share, but here is the part that I think is most relevant to the question:
world = World(RGB(1, 1, 1), 5e-6, shapes, lights, 0.2, 4)
camera = Camera((0, -5000, -5000), 1000, (0, 0, 0), 1920, 1080)
canvas = CUDA.fill(world.background, camera.height, camera.width)
function fillpixel!(arr::CuArray)
height = size(arr)[1]
for j in 1:length(arr)
ind = (j % height, ceil(j / height))
ray = [([ind[2], ind[1]] - [camera.width / 2, camera.height / 2])..., camera.depth]
(ray[2], ray[3]) = (cos(camera.rotation[1] + atan(ray[3], ray[2])), sin(camera.rotation[1] + atan(ray[3], ray[2]))) .* sqrt(ray[2]^2 + ray[3]^2)
(ray[1], ray[3]) = (cos(camera.rotation[2] + atan(ray[3], ray[1])), sin(camera.rotation[2] + atan(ray[3], ray[1]))) .* sqrt(ray[1]^2 + ray[3]^2)
(ray[1], ray[2]) = (cos(camera.rotation[3] + atan(ray[2], ray[1])), sin(camera.rotation[3] + atan(ray[2], ray[1]))) .* sqrt(ray[2]^2 + ray[1]^2)
v = (Inf, nothing, nothing)
for object in world.objects
t = traceray(ray, camera.position, object, mindistance=camera.depth)
t !== nothing && t[1] < v[1] && (v = (t[1], t[2], object))
end
v[1] != Inf && (arr[j] = computecolor(v[3].material, ray, v[1], v[2], world, camera.position .+ v[1] * ray, v[3]))
return nothing
end
end
#cuda fillpixel!(canvas)
but when I run the program, it gives me the following error:
CUDA.jl: ERROR: LoadError: MethodError: no method matching typeof(fillpixel!)(::CuDeviceMatrix{RGB{Float32}, 1})
and I am unable to find out what causes this error and what exactly I'm doing wrong.
Thanks.
Two comments: fillpixel!(arr::CuArray) limits your function to only the type CuArray. CUDA.jl translates the host side representation CuArray to the device side representation `CuDeviceArray. So if you loosen your type restrictions you won't run into this issue.
Secondly you don't want to iterate over the array inside the kernel you launched. You either want to use a function like map or map! to implement the data-parallelism or use the CUDA index primitives.

Why my R seems take forever to run a Mixed effects logistic regression

I indeed got a relatively big dataset and my mixed effects logistic regression is like below. Is that normal to take that long to run? or I made some mistakes?
library(lme4)
glmer_EBRD_undersample_1 <- glmer(leave_happened ~
performance_rating_2016 + performance_rating_2017 + performance_rating_2018 + performance_rating_2019 + performance_rating_2020
+ gender
+ target_group
+ target_pmf_band
+ target_hq_or_ro
+ target_office_location_country_distilled
+ target_org_unit_cost_centre_code_distilled
+ target_ebrd_region_distilled
+ target_contract_group_distilled
+ target_position_tenure_group
+ target_length_of_service_group_distilled
+ leaves_to_date
+ moves_to_date
+ joins_to_date
+ applied_count_to_date
+ line_reviewed_to_date
+ interviewed_to_date
+ offered_to_date
+ hired_to_date
+ (1 | person_id)
,
data = train_undersample_1,
family = binomial,
control = glmerControl(optimizer = "bobyqa"),
nAGQ = 10
)
summary(glmer_EBRD_undersample_1)
Also gave a warning like this: Warning in commonArgs(par, fn, control, environment()) :
maxfun < 10 * length(par)^2 is not recommended.

Confidence Intervals for prediction of a logistic generalized linear mixed model (GLMM)

I am running a logistic generalized linear mixed model and would like to plot my effects together with confidence intervals.
I use the lme4 package to fit my model:
glmer (cbind(positive, negative) ~ F1 * F2 * F3 + V1 + F1 * I(V1^2) + V2 + F1 * I(V2^2) + V3 + I(V3^2) + V4 + I(V4^2) + F4 + (1|OLRE) + (1|ind), family = binomial, data = try, na.action = na.omit, control=glmerControl(optimizer = "optimx", calc.derivs = FALSE, optCtrl = list(method = "nlminb", starttests = FALSE, kkt = FALSE)))
OLRE means that I use an observational level random effect in order to overcome overdispersion.
If you wonder because of convergence warnings, I went through the lme4 troubleshooting protocol, and it should be fine.
In order to get effect plots with confidence intervals, I tried to use ggpredict:
sjPlot, e.g.:
plot_model(mod, type = "pred", terms = c("F1", "F2", "F3"), ci.lvl = 0.95)
I also tried to go through this protocol:
https://rpubs.com/hughes/84484
intdata <- expand.grid(
positive = c(0,1),
negative = c(0,1),
F1 = as.factor(c(0,1)),
F2 = as.factor(c(1,2,3)),
F3= as.factor(c(1,2,3,4)),
V1= as.numeric(median(try$V1)),
F4= as.factor(c(30, 31)),
ind= as.factor(c(68)),
OLRE = as.factor(c(2450)),
V2= as.numeric(median(try$V2)),
V3= as.numeric(median(try$V3)),
V4= as.numeric(median(try$V4))
)
#conditional variances
cV <- ranef(mod, condVar = TRUE)
ranvar <- attr(cV[[1]], "postVar")
sqrt(diag(ranvar[,,1]))
mm <- model.matrix(terms( mod), data=intdata,
contrasts.arg = lapply(intdata[,c(3:5, 7:9)], contrasts, contrasts=FALSE))
predFun<-function(.) mm%*%fixef(.)
bb<-bootMer(mod,FUN=predFun,nsim=3)
with some problems and warnings regarding contrasts and
Error in mm %*% fixef(.) : non-conformable arguments
Therefore, I am wondering if anyone might help me but so far I am not able to Nothing worked so far, so I would really appreciate some help.
Here the link to the data https://drive.google.com/file/d/1qZaJBbM1ggxwPnZ9bsTCXL7_BnXlvfkW/view?usp=sharing

how to create pymol rename loop

I would like to create a loop for changing interactions name in PyMol. But after one selection loop it crashes and doesn't work.
def get_dists(interactions): # interactions=([1,2], [3,4])
for i in interactions:
a = "////" + str(i[0]) + "/C2'"
b = "////" + str(i[1]) + "/C2'"
cmd.distance("(" + a + ")", "(" + b + ")")
for j in range(1, 599):
x = "dist" + "0" + str(j)
y = str(i[0]) + " " + str(i[1])
cmd.set_name(str(x), str(y))
In Pymol the default name of interactions is dist01, 02 , 03.
I want to change these to 1_3, 5_59, 4_8, (interaction between residue).
Your code is totally fine except for one thing: If PyMol doesn't succeed with set_name the whole script is aborted. When you change it to, it should work:
try:
cmd.set_name(str(x), str(y))
except:
print('failed to rename')
Some additional comments:
y = str(i[0]) + " " + str(i[1]) should be y = str(i[0]) + "_" + str(i[1])
this line is probably for padding zeros x = "dist" + "0" + str(j). This is only needed when j is a single digit, otherwise the name of the distance objects is dist20 or dist123
cmd.set_name(str(x), str(y)) can be simplified to cmd.set_name(x, y) since x and y are already strings.

Python for loop for Array

I would like to take mean of a window (5x5).
And this window beginning will move +1 at x axis. After first x axis finished, window will move +1 at y axis and will start a new loop. And I have to say that bant4.tif is an image 512x512.
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
nir = mpimg.imread('bant4.tif')
A = np.array(nir)
for k in range(0,508):
for j in range(0,508):
ilk = A[k][j] + A[k][j+1] + A[k][j+2] + A[k][j+3] + A[k][j+4]
ikinci = A[k+1][j] + A[k+1][j+1] + A[k+1][j+2] + A[k+1][j+3] + A[k+1][j+4]
ucuncu = A[k+2][j] + A[k+2][j+1] + A[k+2][j+2] + A[k+2][j+3] + A[k+2][j+4]
dorduncu = A[k+3][j] + A[k+3][j+1] + A[k+3][j+2] + A[k+3][j+3] + A[k+3][j+4]
besinci = A[k+4][j] + A[k+4][j+1] + A[k+4][j+2] + A[k+4][j+3] + A[k+4][j+4]
ort = (ilk + ikinci + ucuncu + dorduncu + besinci) / 5
ort.tofile('ort.txt')
Here is the error.
Warning (from warnings module):
File "C:\Users\Celik\Desktop\ödev5.py", line 19
ort = (ilk + ikinci + ucuncu + dorduncu + besinci) / 5
RuntimeWarning: overflow encountered in ubyte_scalars
Warning (from warnings module):
File "C:\Users\Celik\Desktop\ödev5.py", line 17
besinci = A[k+4][j] + A[k+4][j+1] + A[k+4][j+2] + A[k+4][j+3] + A[k+4][j+4]
RuntimeWarning: overflow encountered in ubyte_scalars
Warning (from warnings module):
File "C:\Users\Celik\Desktop\ödev5.py", line 14
ikinci = A[k+1][j] + A[k+1][j+1] + A[k+1][j+2] + A[k+1][j+3] + A[k+1][j+4]
RuntimeWarning: overflow encountered in ubyte_scalars
Warning (from warnings module):
File "C:\Users\Celik\Desktop\ödev5.py", line 15
ucuncu = A[k+2][j] + A[k+2][j+1] + A[k+2][j+2] + A[k+2][j+3] + A[k+2][j+4]
RuntimeWarning: overflow encountered in ubyte_scalars
Warning (from warnings module):
File "C:\Users\Celik\Desktop\ödev5.py", line 13
ilk = A[k][j] + A[k][j+1] + A[k][j+2] + A[k][j+3] + A[k][j+4]
RuntimeWarning: overflow encountered in ubyte_scalars
Warning (from warnings module):
File "C:\Users\Celik\Desktop\ödev5.py", line 16
dorduncu = A[k+3][j] + A[k+3][j+1] + A[k+3][j+2] + A[k+3][j+3] + A[k+3][j+4]
RuntimeWarning: overflow encountered in ubyte_scalars

Resources