# HG changeset patch
# User was@debian32.localdomain
# Date 1200676522 28800
# Node ID a66354d137082d833c30dbc577edaccf8ea987a0
# Parent 85934f3b983c44ca9d0ebcd06d5f81492307aae8
Fix trac #1827 -- weird maxima synchronization issues that make themselves known by big calculus expressions breaking on some platforms.
diff -r 85934f3b983c -r a66354d13708 sage/calculus/calculus.py
a
|
b
|
class SymbolicExpressionRing_class(Commu |
440 | 440 | return Integer(0) |
441 | 441 | |
442 | 442 | def _an_element_impl(self): |
443 | | return SymbolicVariable('_generic_variable_name_') |
| 443 | try: |
| 444 | return self.__zero |
| 445 | except AttributeError: |
| 446 | self.__zero = SR(0) |
| 447 | return self.__zero |
444 | 448 | |
445 | 449 | def is_field(self): |
446 | 450 | return True |
diff -r 85934f3b983c -r a66354d13708 sage/interfaces/maxima.py
a
|
b
|
class Maxima(Expect): |
501 | 501 | def _before(self): |
502 | 502 | return self._expect.before |
503 | 503 | |
504 | | def _batch(self, str, batchload=True): |
505 | | F = open(self._local_tmpfile(), 'w') |
506 | | F.write(str) |
| 504 | def _batch(self, s, batchload=True): |
| 505 | filename = '%s-%s'%(self._local_tmpfile(),randrange(2147483647)) |
| 506 | F = open(filename, 'w') |
| 507 | F.write(s) |
507 | 508 | F.close() |
508 | | tmp_to_use = self._local_tmpfile() |
509 | 509 | if self.is_remote(): |
510 | | self._send_tmpfile_to_server() |
| 510 | self._send_tmpfile_to_server(local_file=filename) |
511 | 511 | tmp_to_use = self._remote_tmpfile() |
| 512 | tmp_to_use = filename |
512 | 513 | |
513 | 514 | if batchload: |
514 | 515 | cmd = 'batchload("%s");'%tmp_to_use |
515 | 516 | else: |
516 | 517 | cmd = 'batch("%s");'%tmp_to_use |
| 518 | |
| 519 | r = randrange(2147483647) |
| 520 | s = str(r+1) |
| 521 | cmd = "%s1+%s;\n"%(cmd,r) |
| 522 | |
517 | 523 | self._sendline(cmd) |
518 | | self._expect_expr() |
| 524 | self._expect_expr(s) |
519 | 525 | out = self._before() |
520 | 526 | self._error_check(str, out) |
| 527 | os.unlink(filename) |
521 | 528 | return out |
522 | 529 | |
523 | 530 | def _error_check(self, str, out): |
… |
… |
class Maxima(Expect): |
540 | 547 | self._synchronize() |
541 | 548 | |
542 | 549 | if len(line) > self.__eval_using_file_cutoff: |
| 550 | # This implicitly uses the set method, then displays the result of the thing that was set. |
| 551 | # This only works when the input line is an expression. But this is our only choice, since |
| 552 | # batchmode doesn't display expressions to screen. |
543 | 553 | a = self(line) |
544 | 554 | return repr(a) |
545 | 555 | else: |
diff -r 85934f3b983c -r a66354d13708 sage/plot/plot3d/transform.pyx
a
|
b
|
def rotate_arbitrary(v, double theta): |
203 | 203 | sage: m = rotX(theta) * m |
204 | 204 | |
205 | 205 | Do some simplfying here to avoid blow-up. |
206 | | sage: ix = [(i,j) for i in range(3) for j in range(3)] |
207 | | sage: for ij in ix: m[ij] = m[ij].simplify_rational() |
| 206 | sage: m = m.simplify_rational() |
208 | 207 | |
209 | 208 | Now go back to the original coordinate system. |
210 | 209 | sage: m = rotZ(-s) * m |
211 | 210 | sage: m = rotX(-t) * m |
212 | | sage: for ij in ix: m[ij] = m[ij].simplify_rational() |
| 211 | sage: m = m.simplify_rational() |
213 | 212 | sage: m |
214 | | [ (x^2*z^2 - (cos(theta)*x^2 - cos(theta))*z^2)/z^2 (-sqrt(-z^2 - x^2 + 1)*(cos(theta)*x*abs(z) - x*abs(z)) - sin(theta)*z^2)/abs(z) (-cos(theta)*x*z^2*abs(z) + x*z^2*abs(z) + sin(theta)*z^2*sqrt(-z^2 - x^2 + 1))/(z*abs(z))] |
215 | | [ (sin(theta)*z^2*abs(z) - sqrt(-z^2 - x^2 + 1)*(cos(theta)*x*z^2 - x*z^2))/z^2 ((-(x^2 + cos(theta) - 1)*z^2 - x^4 + 2*x^2 - 1)*abs(z) - (-cos(theta)*x^2*z^2 - cos(theta)*x^4 + cos(theta)*x^2)*abs(z))/((x^2 - 1)*abs(z)) (-sqrt(-z^2 - x^2 + 1)*(cos(theta)*x^2*z^2*abs(z) + (-x^2 - cos(theta) + 1)*z^2*abs(z)) + sin(theta)*x*z^4 - z^2*(sin(theta)*x*z^2 + sin(theta)*x^3 - sin(theta)*x))/((x^2 - 1)*z*abs(z))] |
216 | | [ (-sin(theta)*z*sqrt(-z^2 - x^2 + 1)*abs(z) - cos(theta)*x*z^3 + x*z^3)/z^2 (-sqrt(-z^2 - x^2 + 1)*(cos(theta)*x^2*z*abs(z) + (-x^2 - cos(theta) + 1)*z*abs(z)) - (sin(theta)*x - sin(theta)*x^3)*z)/((x^2 - 1)*abs(z)) (((x^2 + cos(theta) - 1)*z^2 + cos(theta)*x^2 - cos(theta))*abs(z) - cos(theta)*x^2*z^2*abs(z))/((x^2 - 1)*abs(z))] |
217 | | |
| 213 | [ (1 - cos(theta))*x^2 + cos(theta) (-sin(theta)*abs(z)^3 - (cos(theta) - 1)*x*z^2*sqrt(-z^2 - x^2 + 1))/z^2 (sin(theta)*sqrt(-z^2 - x^2 + 1)*abs(z)^3 + (1 - cos(theta))*x*z^4)/z^3] |
| 214 | [ sin(theta)*abs(z) + (1 - cos(theta))*x*sqrt(-z^2 - x^2 + 1) (cos(theta) - 1)*z^2 + (cos(theta) - 1)*x^2 + 1 (-sin(theta)*x*abs(z) - (cos(theta) - 1)*z^2*sqrt(-z^2 - x^2 + 1))/z] |
| 215 | [ (-sin(theta)*sqrt(-z^2 - x^2 + 1)*abs(z) - (cos(theta) - 1)*x*z^2)/z (sin(theta)*x*abs(z) - (cos(theta) - 1)*z^2*sqrt(-z^2 - x^2 + 1))/z (1 - cos(theta))*z^2 + cos(theta)] |
218 | 216 | |
219 | 217 | Re-expressing some entries in terms of y and resolving the absolute |
220 | 218 | values introduced by eliminating y, we get the desired result. |