2021-04-09 01:22:55 +0200 | received badge | ● Notable Question
(source)
|
2021-04-09 01:22:54 +0200 | received badge | ● Popular Question
(source)
|
2021-03-13 14:06:25 +0200 | received badge | ● Famous Question
(source)
|
2020-10-06 17:45:02 +0200 | received badge | ● Notable Question
(source)
|
2017-10-25 10:03:27 +0200 | received badge | ● Popular Question
(source)
|
2017-05-09 23:58:52 +0200 | received badge | ● Popular Question
(source)
|
2017-04-10 18:04:05 +0200 | received badge | ● Famous Question
(source)
|
2017-03-10 09:22:04 +0200 | received badge | ● Notable Question
(source)
|
2017-03-10 09:22:04 +0200 | received badge | ● Popular Question
(source)
|
2016-08-01 10:03:43 +0200 | received badge | ● Notable Question
(source)
|
2014-10-11 17:01:45 +0200 | received badge | ● Popular Question
(source)
|
2014-06-29 03:15:38 +0200 | marked best answer | convert expression to QuadraticField I tried (in the Sage shell) K = QuadraticField(-3)
a = K(sqrt(-3))
But that fails with a TypeError exception. What is the problem? I know that I can get the generator by K.gen() but I want to be able to convert expressions to K . |
2013-06-10 09:52:03 +0200 | marked best answer | how to use variables (`var`) This is a known issue, see for example trac ticket 6862, and ask question 2287. What you can do is to use the assume function, as in the following: sage: t1,t2,t4 = var("t1 t2 t4")
sage: assume(t2,'complex')
sage: t2.conjugate().simplify()
conjugate(t2)
sage: t2.real().simplify()
realpart(t2)
sage: t2.imag().simplify()
imagpart(t2)
|
2013-06-10 09:27:53 +0200 | asked a question | how to use variables (`var`) I thought they are complex by default. But even when I try to force the domain to be complex, I always get x.conjugate().simplify() == x . Why? See also below: sage: t1,t2,t4 = var("t1 t2 t4")
sage: t2.conjugate().simplify()
t2
sage: t1,t2,t4 = var("t1 t2 t4", domain="complex")
sage: t2
t2
sage: t2.is_real()
False
sage: t2.conjugate().simplify()
t2
sage: (t2.real()*2 - t2).simplify()
t2
sage: t2.real().simplify()
t2
sage: t2.imag().simplify()
0
|
2013-06-04 07:38:15 +0200 | commented answer | SIGILL in forked process [Here](http://stackoverflow.com/a/16878397/133374), I got some response from someone working at Apple. He says that using libBLAS in a forked process is not safe. I haven't really investigated yet. But it would mean that Sage is not safe to use in a forked process. |
2013-06-03 13:27:39 +0200 | commented answer | SIGILL in forked process It only happens in the forked process. Matrix multiplications work fine otherwise. |
2013-05-31 15:08:41 +0200 | marked best answer | run Python file from command line in Sage It is enough to add to sageruntest.py: from sage.all import *
from sage.matrix.matrix2 import Matrix
Alternatively, the 2nd line (yours) is enough if you rename your file to sageruntest.sage (then it will be preparsed by Sage). |
2013-05-31 09:25:44 +0200 | asked a question | run Python file from command line in Sage I'm trying to run some Python file with Sage. I can import the module just fine within the interactive Sage IPython shell. However, this very simple test fails: sage sageruntest.py
where sageruntest.py contains the single line: from sage.matrix.matrix2 import Matrix
It fails with: Traceback (most recent call last):
File "sageruntest.py", line 1, in <module>
from sage.matrix.matrix2 import Matrix
File "matrix2.pyx", line 1, in init sage.matrix.matrix2 (sage/matrix/matrix2.c:71259)
File "matrix1.pyx", line 1, in init sage.matrix.matrix1 (sage/matrix/matrix1.c:13931)
File "matrix0.pyx", line 32, in init sage.matrix.matrix0 (sage/matrix/matrix0.c:29567)
File "/Applications/sage-5.9/local/lib/python2.7/site-packages/sage/modules/free_module.py", line 163, in <module>
import free_module_element
File "integer.pxd", line 9, in init sage.modules.free_module_element (sage/modules/free_module_element.c:30936)
File "integer.pyx", line 178, in init sage.rings.integer (sage/rings/integer.c:38404)
File "/Applications/sage-5.9/local/lib/python2.7/site-packages/sage/rings/infinity.py", line 203, in <module>
import sage.rings.rational
File "fast_arith.pxd", line 5, in init sage.rings.rational (sage/rings/rational.c:27749)
File "fast_arith.pyx", line 51, in init sage.rings.fast_arith (sage/rings/fast_arith.c:8051)
File "integer_ring.pyx", line 67, in init sage.rings.integer_ring (sage/rings/integer_ring.c:12156)
File "/Applications/sage-5.9/local/lib/python2.7/site-packages/sage/structure/factorization.py", line 188, in <module>
from sage.misc.all import prod
File "/Applications/sage-5.9/local/lib/python2.7/site-packages/sage/misc/all.py", line 85, in <module>
from functional import (additive_order,
File "/Applications/sage-5.9/local/lib/python2.7/site-packages/sage/misc/functional.py", line 36, in <module>
from sage.rings.complex_double import CDF
File "complex_double.pyx", line 87, in init sage.rings.complex_double (sage/rings/complex_double.c:16745)
File "real_mpfr.pxd", line 15, in init sage.rings.complex_number (sage/rings/complex_number.c:18304)
File "real_mpfr.pyx", line 1, in init sage.rings.real_mpfr (sage/rings/real_mpfr.c:33344)
File "utils.pyx", line 11, in init sage.libs.mpmath.utils (sage/libs/mpmath/utils.c:6633)
File "/Applications/sage-5.9/local/lib/python2.7/site-packages/sage/all.py", line 86, in <module>
from sage.libs.all import *
File "/Applications/sage-5.9/local/lib/python2.7/site-packages/sage/libs/all.py", line 1, in <module>
import sage.libs.ntl.all as ntl
File "/Applications/sage-5.9/local/lib/python2.7/site-packages/sage/libs/ntl/__init__.py", line 1, in <module>
import all
File "/Applications/sage-5.9/local/lib/python2.7/site-packages/sage/libs/ntl/all.py", line 26, in <module>
from sage.libs.ntl.ntl_ZZ import (
File "ntl_ZZ.pyx", line 24, in init sage.libs.ntl.ntl_ZZ (sage/libs/ntl/ntl_ZZ.cpp:7011)
ImportError: cannot import name IntegerRing
I just stumbled upon local/bin/sage-eval which imports this at the beginning: import sys
from sage.all import *
from sage.calculus.predefined import x
from sage.misc.preparser import preparse
When I do ... (more) |
2013-05-31 08:31:14 +0200 | commented answer | SIGILL in forked process In most cases, one output. Sometimes more. I get the feeling that this is MacOSX related. |
2013-05-31 08:23:54 +0200 | commented answer | SIGILL in forked process It happens if you called `_fork_test_func()` also in the parent process before the fork. I slightly extended my last simple test case. With that test case, it also crashes in a fresh Sage session. |
2013-05-31 08:16:49 +0200 | commented answer | SIGILL in forked process No, I don't get an error with `print 1+1`. I think it only happens when I call other more complicated functions from Sage. I am just playing more around and I just figured out that the crash also doesn't happen in a fresh session with my other example. So some internal state caused this. I try to work on a test case which also works in a fresh Sage session. |
2013-05-31 06:54:19 +0200 | commented answer | SIGILL in forked process I also tried to use pure Python functions. It does not crash it that case for me neither. But see my `_fork_test_func` and try with that one. I downloaded the MacOSX binaries. That is Sage 5.8. |
2013-05-31 06:13:24 +0200 | commented answer | where is `sage.databases.db.Database-` I tried so far as that I just did that (see my commits [here](https://github.com/martinra/psage/pull/1)) and it imports fine but I'm not sure if it really works. That was not important for me as other stuff from PSage works now (which failed before because of the failing import) with a more recent Sage (5.8 and 5.9). |
2013-05-31 04:57:19 +0200 | asked a question | SIGILL in forked process I am playing around with fork. I have a very simple test case which is basically like this: def fork_test():
import os
pid = os.fork()
if pid != 0:
print "parent, child: %i" % pid
os.waitpid(pid, 0)
else:
print "child"
try:
# some dummy matrix calculation
finally:
os._exit(0)
(See _fork_test_func() below for some sample matrix calculations.) And I'm getting: ------------------------------------------------------------------------
Unhandled SIGILL: An illegal instruction occurred in Sage.
This probably occurred because a *compiled* component of Sage has a bug
in it and is not properly wrapped with sig_on(), sig_off(). You might
want to run Sage under gdb with 'sage -gdb' to debug this.
Sage will now terminate.
------------------------------------------------------------------------
With this (incomplete) backtrace: Crashed Thread: 0 Dispatch queue: com.apple.root.default-priority
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Application Specific Information:
BUG IN LIBDISPATCH: flawed group/semaphore logic
Thread 0 Crashed:: Dispatch queue: com.apple.root.default-priority
0 libsystem_kernel.dylib 0x00007fff8c6d1d46 __kill + 10
1 libcsage.dylib 0x0000000101717f33 sigdie + 124
2 libcsage.dylib 0x0000000101717719 sage_signal_handler + 364
3 libsystem_c.dylib 0x00007fff86b1094a _sigtramp + 26
4 libdispatch.dylib 0x00007fff89a66c74 _dispatch_thread_semaphore_signal + 27
5 libdispatch.dylib 0x00007fff89a66f3e _dispatch_apply2 + 143
6 libdispatch.dylib 0x00007fff89a66e30 dispatch_apply_f + 440
7 libBLAS.dylib 0x00007fff906ca435 APL_dtrsm + 1963
8 libBLAS.dylib 0x00007fff906702b6 cblas_dtrsm + 882
9 matrix_modn_dense_double.so 0x0000000108612615 void FFLAS::Protected::ftrsmRightLowerNoTransUnit<double>::delayed<FFPACK::Modular<double> >(FFPACK::Modular<double> const&, unsigned long, unsigned long, FFPACK::Modular<double>::Element*, unsigned long, FFPACK::Modular<double>::Element*, unsigned long, unsigned long, unsigned long) + 2853
10 matrix_modn_dense_double.so 0x0000000108611daa void FFLAS::Protected::ftrsmRightLowerNoTransUnit<double>::delayed<FFPACK::Modular<double> >(FFPACK::Modular<double> const&, unsigned long, unsigned long, FFPACK::Modular<double>::Element*, unsigned long, FFPACK::Modular<double>::Element*, unsigned long, unsigned long, unsigned long) + 698
11 matrix_modn_dense_double.so 0x0000000108612ccf void FFLAS::Protected::ftrsmRightLowerNoTransUnit<double>::operator()<FFPACK::Modular<double> >(FFPACK::Modular<double> const&, unsigned long, unsigned long, FFPACK::Modular<double>::Element*, unsigned long, FFPACK::Modular<double>::Element*, unsigned long) + 831
12 ??? 0x00007f99e481a028 0 + 140298940424232
Thread 1:
0 libsystem_kernel.dylib 0x00007fff8c6d26d6 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff86b24f4c _pthread_workq_return + 25
2 libsystem_c.dylib 0x00007fff86b24d13 _pthread_wqthread + 412
3 libsystem_c.dylib 0x00007fff86b0f1d1 start_wqthread + 13
Thread 2:
0 libsystem_kernel.dylib 0x00007fff8c6d26d6 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff86b24f4c _pthread_workq_return + 25
2 libsystem_c.dylib 0x00007fff86b24d13 _pthread_wqthread + 412
3 libsystem_c.dylib 0x00007fff86b0f1d1 start_wqthread + 13
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x00007fff5ec8e418 rcx: 0x00007fff5ec8df28 rdx: 0x0000000000000000
rdi: 0x000000000000b8f7 rsi: 0x0000000000000004 rbp: 0x00007fff5ec8df40 rsp: 0x00007fff5ec8df28
r8: 0x00007fff5ec8e418 r9: 0x0000000000000000 r10: 0x000000000000000a r11: 0x0000000000000202
r12: 0x00007f99ea500de0 r13: 0x0000000000000003 r14: 0x00007fff5ec8e860 r15: 0x00007fff906ca447
rip: 0x00007fff8c6d1d46 rfl: 0x0000000000000202 cr2: 0x00007fff74a29848
Logical CPU: 0
Is there something special I need to do after a fork ? I looked up the fork decorator of Sage and it looks like it basically does the same. The crash also happens with the fork decorator of Sage itself. Another test case: def fork_test2():
def test():
# do some stuff
from sage.parallel.decorate import fork
test_ = fork(test, verbose=True)
test_()
Even simpler test case: def _fork_test_func():
while True:
m = matrix(QQ, 100, [randrange(-100,100) for i in range(100*100 ... (more) |
2013-05-25 11:36:30 +0200 | asked a question | where is `sage.databases.db.Database-` I am trying to port some older Sage code (I think for Sage 5.4 or so). It uses sage.databases.db.Database but that doesn't seem to exist anymore. Where is it? The file I'm trying to update is euler_database.py . Edit: Can I just use from sage.databases.all import SQLDatabase as Database
? |
2013-05-25 10:14:10 +0200 | received badge | ● Supporter
(source)
|
2013-05-25 10:14:06 +0200 | received badge | ● Scholar
(source)
|
2013-05-25 10:14:06 +0200 | marked best answer | convert expression to QuadraticField Hi, You should avoid usage of the symbolic ring as much as possible. It is useful to deal with functions, derivations and such but not to deal with arithmetic questions. There is a class called AlgebraicConverter in sage.symbolic.expression_conversions which is implemented and called in such case. It works well for the field of algebraic numbers QQbar :: sage: QQbar(sqrt(-3))
1.732050807568878?*I
sage: QQbar(sin(pi/4))
0.7071067811865475?
But not for other number fields. Nevertheless it is possible to do sage: K = QuadraticField(-3)
sage: K(3).sqrt()
a
The method sqrt above actually uses Pari in the background: if your number field contains such a root it returns it, otherwise the answer will be an element of the symbolic ring. sage: K(3).sqrt().sqrt()
3^(1/4)
|
2013-05-25 10:13:05 +0200 | asked a question | `sage -sh` on Mac I got the instruction to use sage -sh to install some PSage modules. However, many environment variables seem to be messed up. It has /usr/local/bin and others prioritized before the Sage dirs. I manually edited the $PATH variable to update this issue, via set PATH /Applications/sage-5.8/spkg/bin /Applications/sage-5.8/local/bin /usr/bin/ /bin /sbin . However, now Cython still has problems to find the right module. When starting it, it looks like: az@ip229 ~/P/psage> cython -h
Traceback (most recent call last):
File "/Applications/sage-5.8/local/bin/cython", line 7, in <module>
from Cython.Compiler.Main import main
File "/Library/Python/2.7/site-packages/Cython-0.18-py2.7-macosx-10.8-x86_64.egg/Cython/Compiler/Main.py", line 17, in <module>
from Scanning import PyrexScanner, FileSourceDescriptor
ImportError: dlopen(/Library/Python/2.7/site-packages/Cython-0.18-py2.7-macosx-10.8-x86_64.egg/Cython/Compiler/Scanning.so, 2): Symbol not found: _PyUnicodeUCS2_Compare
Referenced from: /Library/Python/2.7/site-packages/Cython-0.18-py2.7-macosx-10.8-x86_64.egg/Cython/Compiler/Scanning.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/Cython-0.18-py2.7-macosx-10.8-x86_64.egg/Cython/Compiler/Scanning.so
Update: Doing set PYTHONPATH /Applications/sage-5.8/local/lib/python fixed at least this particular problem with Cython. Is there any suggestion about what I can do to easily overcome these problems? |