Ask Your Question

Bark's profile - activity

2021-03-31 12:33:52 +0100 received badge  Popular Question (source)
2021-01-19 21:06:54 +0100 received badge  Popular Question (source)
2020-10-13 07:49:18 +0100 asked a question Tensor decomposition and Tensorly

I have a 3 x 3 x 3 tensor and I am looking to compute its tensor rank (https://en.wikipedia.org/wiki/Tensor_...), aka CP rank. The only software in Python that I am currently aware of to do this is Tensorly, a Python package.

Is there anything in Sage itself that deals with tensor decomposition or any implementation of the Alternative Least Squares method (I believe this is the most common method for tensor decomposition) within Sage?

I am currently running Sage v 8.1

Thank you for your time!

2020-09-13 01:06:08 +0100 commented answer Convert sage code from v8.1 to work in v9.1

Thank you! This is precisely what I was looking for!

2020-09-12 04:29:51 +0100 asked a question Convert sage code from v8.1 to work in v9.1

Hi all,

I have a .sage file that works with Sage v8.1, however, it does not run with Sage v9.1. It seems the issues are the same issues that occur with Python2 vs Python3 syntax i.e. print statement syntax is print 'statement' vs print('statement')

Rather than go through line by line and find each difference, is there a way to convert the file to make it run for Sage 9.0 and later?

Any assistance would be appreciated!

2020-02-09 07:10:44 +0100 commented answer Tensor Product of Quotient Rings

Thank you! I understand the use of the theorem that $k[X] \otimes k[Y] \simeq k[X \times Y]$, but I wasn't sure if there was a tensor product class, like there is for free modules.

2020-02-07 07:05:04 +0100 asked a question Tensor Product of Quotient Rings

I would like to know how to do a tensor product of two quotient rings in Sage. I have the following toy example that I am using to try and understand the concept

    R = PolynomialRing(QQ,2,'x')
    R.inject_variables()
    IR = ideal(x0^2-x1^3)
    QR = QuotientRing(R,IR)

    S = PolynomialRing(QQ,3,'x')
    S.inject_variables()
    IS = ideal(x0*x1-x2^2)
    QS = QuotientRing(R,IS)

Both rings are in the variables labeled by x, but I would like to treat each set of variables as if they are different. Any help would be appreciated!

2020-01-06 18:28:53 +0100 commented answer Singular Implementation for Multivariable Polynomial Rings in v7.3

Hi! Thank you for your input! Our IT department is currently undergoing restructuring and so I have not been able to get in touch with the admins, as that was the first thing I tried to do! I will see if I can compile a recent version of Sage on the account. I believe I can try to get that distro, thank you!

2020-01-05 21:21:01 +0100 asked a question Singular Implementation for Multivariable Polynomial Rings in v7.3

Hi all,

I am running SageMath version 7.3, Release Date: 2016-08-04 on a university computer.

When I try to run the code:

S = PolynomialRing(QQ, 5, "x", implementation="singular")

I get in return:

ValueError: The singular implementation is not known for multivariate polynomial rings

However, on my personal laptop, where I run version 8.1, I do not have this error. Is there anyway to fix this on 7.3 without updating, since I do not have administrator permissions. Thank you for your time!

2019-09-20 22:25:00 +0100 asked a question Batch file and Sage

Hi,

I am using SLURM (https://slurm.schedmd.com/) to run a batch process on a cluster of computers. Here is the following .slrm file that I have:

#!/bin/bash
#SBATCH --time=1:59:00
#SBATCH --ntasks=1
#SBATCH --mem=3820
#SBATCH -O
#SBATCH --output=/data/scratch/kbari/slrmbt_%A_%a.out
#SBATCH --array=1-50

sage --nodotsage /data/scratch/kbari/slurmbatchtest.py $SLURM_ARRAY_TASK_ID

I get an error that: "Error: HOME directory '/u/grad/kbari' does not exist. Error setting environment variables by sourcing '/usr/local/SageMath/src/bin/sage-env'; possibly contact sage-devel (see http://groups.google.com/group/sage-d...

I understand the error to be that it is trying to access sage from a different directory, which it does not have access to and cannot find as a result. So how can I change the environment variable to just tell it to run Sage not from that directory?

Thanks for your time!

2019-07-21 16:43:52 +0100 received badge  Nice Question (source)
2019-07-18 14:00:49 +0100 asked a question Concatenate two sparse matrices over a Polynomial Ring

Hi all,

I am wondering if there is a way to concatenate two sparse matrices over a polynomial ring. Here is a toy example that I am testing with:

S.<x,y> = PolynomialRing(QQ,2)

udict = {(0,0):1, (0,1):x, (1,1):y}
vdict = {(0,0):2*x,(1,0):y}

U = matrix(4,4,ud,sparse=True)
V = matrix(4,2,vd,sparse=True)

I would like to make a larger matrix that is $4 \times 6$, that has the block form $[U|V]$. I attempted to use the block_matrix command, but it said that the given number of rows and columns were incompatible with the number of submatrices.

In Python, for a sparse matrix (csr_matrix or coo_matrix), there is the command hstack from scipy.sparse. Is there a similar command where I can concatenate a list of these sparse matrices? This would be ideal for my general problem.

Thank you for your time!

2019-07-17 17:49:28 +0100 asked a question Matrix multiplication of sparse matrix with matrix over polynomial ring

Hi all,

I would like to know how to multiply the following matrices I have constructed in Sage. Here is my code for a toy example:

from scipy.sparse import csr_matrix
row = [0,0,1]
col = [0,1,1]
data = [1,-1,1]
A = csr_matrix((data,(row,col)),shape=(4,4))


R.<x,y> = PolynomialRing(QQ,2)
B = matrix(R,2,2,[1,x,1,y])

When I try to multiply the matrices using A.dot(B), I end up with the error: "No supported conversion for types: (dtype('int64'), dtype('O'))"

Is there a way I can multiply these matrices and yield an output that is a csr_matrix? (I suspect I would want to convert the entries of my A matrix to be the same data type, but I am unaware of how to do this)

Thank you for your time!

2019-07-17 17:31:35 +0100 received badge  Scholar (source)
2019-07-17 07:36:00 +0100 commented answer Create Matrix in RREF with indeterminates

Thank you, this is perfect!

2019-07-17 07:28:02 +0100 received badge  Supporter (source)
2019-07-16 19:45:28 +0100 received badge  Student (source)
2019-07-16 17:39:11 +0100 received badge  Organizer (source)
2019-07-16 17:38:32 +0100 received badge  Editor (source)
2019-07-16 17:36:05 +0100 asked a question Create Matrix in RREF with indeterminates

Hi all,

I would like to be able to create a Matrix over a multivariable polynomial ring (in particular over R = PolynomialRing(QQ, 'x',(n-k)*n)) in Sage that has a particular form. I would like to create a $k \times n$ matrices that is in RREF form, where I can choose where the pivots should be and fill in the rest with variables from my polynomial ring. (I am assuming full rank, so there will be $k$ pivots with $n \choose k$ possible choices)

$\begin{bmatrix} 1 & x1 & 0 & x2 & \cdots\\ 0 & 0 & 1 & x3 & \cdots\\ 0 & 0 & 0 & 0 &\cdots \\ \vdots & \vdots & \vdots & \vdots & \ddots \end{bmatrix}$

Is there any way I can do this in Sage by just indicating which columns I want to have the pivots in?

2019-05-30 08:08:16 +0100 asked a question Order Filter of Poset

Hi,

I have a finite Poset and would list to find all Order Filters of the Poset with a particular cardinality. Is there a way to do this without having to iterate over all Order Filters of my Poset? My Poset can have lots of elements, so if I were to iterate over all order filters generated by all subsets of those elements, it may take a long time.