Questions tagged [symmetric]

is used in its general meaning, so you are encouraged to use one or more tags in addition to this tag, to describe your case better.

An example of Symmetric would be a Symmetric Key, which is used in both the sides of an algorithm in cryptography.

170 questions
3
votes
2 answers

C Matrix Program

I have a matrix program that so far takes an input file in and expresses the numbers in matrices. I also wrote a function to find its transpose but I can't figure out how to do the symmetrical. I have to take only 3 input parameters…
3
votes
2 answers

numpy: find symmetric values in 2d arrays

I have to analyze a quadratic 2D numpy array LL for values which are symmetric (LL[i,j] == LL[j,i]) and not zero. Is there a faster and more "array like" way without loops to do this? Is there a easy way to store the indices of the values for…
3
votes
5 answers

Checking if array is symmetric

public class symm { /* * Returns true if array A is symmetric. * Returns false otherwise. * n is the number of elements A contains. * * The running time of your algorithm is O( ). * You may add a brief explanation here if you wish. */ …
Moe
  • 33
  • 1
  • 1
  • 4
3
votes
1 answer

From asymmetric matrix (or dataframe) into a symmetric square matrix with R

Given this data.frame: 'sample', which represents pairwise wins and losses among species: sp1<-c(0,1,0) sp3<-c(1,2,2) sp5<-c(3,1,0) sample<-as.data.frame(cbind(sp1,sp3,sp5)) rownames(sample)<-c("sp1","sp6","sp8") which…
2
votes
2 answers

Compute symmetric matrix of a large file with awk

I have an OD matrix (origin-destination matrix) written in list form, like this inputfile.csv: "origin_id","destination_id","trips" "0","0","20" "0","1","12" "0","2","8" "1","0","23" "1","1","50" "1","2","6" "2","1","9" "2","2","33" Which reads…
ElTitoFranki
  • 375
  • 1
  • 7
2
votes
5 answers

How do I make a symmetric matrix using R?

I am trying to make a symmetric matrix using R. I already have a matrix. My matrix is very big so below is a simple example. EX. 1 2 3 4 5 6 7 8 9 I need to make them like this. 1 2+4 3+7 4+2 5 6+8 7+3 8+6 9 //So I tried this. // mat is…
Mir
  • 63
  • 6
2
votes
1 answer

Creating a symmetric array with power of an element

I am trying to create an array which is symmetric with elements placed as below I have written the following code to get this form with parameter being 0.5 and dimension being 4-by-4. import numpy as np a = np.eye(4) for i in range(4): for j in…
learner
  • 3,168
  • 3
  • 18
  • 35
2
votes
1 answer

How to efficiently calculate only the upper triangle of this operation in Python?

I am doing a calculation that measures the difference between values in a pd.Series. Although it is a vector operation and done in one go, I feel that it is inefficient in that it also calculates the values for the lower triangle as well as the…
O.rka
  • 29,847
  • 68
  • 194
  • 309
2
votes
1 answer

Convert array from np.triu_indices to symmetric matrix

I can easily convert a symmetric matrix to an array/1-d matrix of one of its triangular components using A_symmetric = np.matrix([[1,2][2,3]]) A_array = A_symmetric[np.triu_indices(2)] == np.matrix([1,2,3]) (and similary with tril_indices) But how…
Frank Vel
  • 1,202
  • 1
  • 13
  • 27
2
votes
1 answer

Symmetric matrices in numpy?

I wish to initiate a symmetric matrix in python and populate it with zeros. At the moment, I have initiated an array of known dimensions but this is unsuitable for subsequent input into R as a distance matrix. Are there any 'simple' methods in numpy…
Darren J. Fitzpatrick
  • 7,159
  • 14
  • 45
  • 49
2
votes
1 answer

How to verify a GMAC?

According to section 5.2 (Two GCM Functions) of the Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC, it mentions that for the case of GMAC, the authenticated encryption and decryption functions become the…
ktulinho
  • 3,870
  • 9
  • 28
  • 35
2
votes
1 answer

How to symmetrize a sparse matrix in Eigen C++?

I have a sparse matrix A in Eigen C++. Now I want to symmetrize it to another sparse matrix Asym: I was hoping that it would be as simple as: Eigen::SparseMatrix A; ... Eigen::SparseMatrix Asym = 0.5*(A+A.transpose()); // error…
user62039
  • 371
  • 2
  • 15
2
votes
3 answers

For loops to create symmetric matrices

I want to reduce time and memory usage (I previously used outer for this but it consumes more memory than I have) by reducing the iterations to create a symmetric matrix, that is sol[i, j] is the same as sol[j, i]. My code so far: # Prepare…
llrs
  • 3,308
  • 35
  • 68
2
votes
2 answers

how can I check if a BST is symmetric in its structure

I'm coding a program and i need to know if a BST is symmetric in its structure public void traverse (Layer root){ if (root.leftChild != null){ traverse (root.leftChild); } if (root.rightChild != null){ …
2
votes
0 answers

Scale and computer cosine similarity of co-occurrence matrix

I have a co-occurrence symmetric matrix (1877 x 1877). I treat columns as features and compute the cosine distance between them. Before that, I scale the matrix (center to the mean and component wise scale to unit variance). from sklearn import…
1 2
3
11 12