Ask Your Question

more_weight's profile - activity

2023-07-23 06:13:31 +0200 received badge  Famous Question (source)
2023-07-03 19:24:02 +0200 received badge  Notable Question (source)
2023-07-03 19:24:02 +0200 received badge  Popular Question (source)
2023-02-09 00:22:00 +0200 commented question Is it no longer possible to calculate SVD in sage?

Thanks for the reply. Yes, your mwe works. I think my issue is that my matrix was originally defined as a "sparse" matr

2023-02-08 18:32:57 +0200 asked a question Is it no longer possible to calculate SVD in sage?

Is it no longer possible to calculate SVD in sage? I recently noticed that the property .SVD() is no longer available fo

2020-10-16 16:56:00 +0200 commented answer Can attributes of sage classes be changed?

Really cool idea! Thanks!

2020-10-15 20:46:05 +0200 commented answer Can attributes of sage classes be changed?

This isn't quite what I want. The commas are still there and the numbers are not inside an array.

2020-10-14 20:37:14 +0200 received badge  Scholar (source)
2020-10-14 20:37:12 +0200 received badge  Supporter (source)
2020-10-14 20:37:10 +0200 commented answer Is there a reliable way to check if an object is a vector?

Ha. Had no idea this was built in. Thanks!

2020-10-14 18:07:09 +0200 received badge  Student (source)
2020-10-14 17:57:18 +0200 asked a question Is there a reliable way to check if an object is a vector?

I'm want to check if a given sage object obj is a vector or not. I'd like to do this as efficiently as possible. Currently my best idea is:

sage_input(obj).__repr__().startswith('vector')

This works, assuming that sage_input is smart enough to identify every vector without false positives. However, this solution feels inefficient (and also inelegant!). Is there a better way?

2020-10-14 06:03:32 +0200 commented question Can attributes of sage classes be changed?

Are there any workarounds?

2020-10-14 01:00:51 +0200 asked a question Can attributes of sage classes be changed?

I want to change the way vectors are rendered in sagetex. For example, consider v = vector([1, 2, 3]). In sagetex, the command $v=\sage{v}$ renders as $$ v=(1, 2, 3) $$ Instead, I want my vectors to take the form $$ v=\left[\begin{array}{rrr}1&2&3\end{array}\right]^\intercal $$ I thought I could do this by resetting the _latex_ method of the sage.modules.free_module_element.FreeModuleElement class as follows.

def my_vector_latex(self):
    return matrix(v)._latex_() + r'^\intercal'

setattr(sage.modules.free_module_element.FreeModuleElement, '_latex_', my_vector_latex)

However, this code throws the following error:

TypeError: can't set attributes of built-in/extension type 'sage.modules.free_module_element.FreeModuleElement'

So, it looks like I can't modify the methods of FreeModuleElement in this way. Is there anything else I could do?

2020-10-14 01:00:51 +0200 asked a question Can _latex_ methods be locally altered?

I'm writing a latex document where I want all vectors to be represented differently in sagetex. Is this possible?

More specifically, in sagetex, the vector v=vector([1, 2, 3]) renders as \left(1,\,2,\,3\right) in sagetex. Instead, I want vectors rendered as transposes of column matrices \left[\begin{array}{rrr}1 & 2 & 3\end{array}\right]^T.