def upper_tri_to_full(n):
 entries = ((n * (n + 1)) // 2)
 val_arr = []
 row_arr = []
 col_arr = []
 count = 0
 for i in range(n):
  for j in range(i, n):
   col_arr.append(count)
   row_arr.append(((j * n) + i))
   val_arr.append(1.0)
   if (i != j):
    col_arr.append(count)
    row_arr.append(((i * n) + j))
    val_arr.append(1.0)
   count += 1
 return sp.coo_matrix((val_arr, (row_arr, col_arr)), ((n * n), entries)).tocsc()

def upper_tri_to_full ( n ) : entries = ( ( n * ( n + 1 ) ) // 2 ) val_arr = [ ] row_arr = [ ] col_arr = [ ] count = 0 for i in range ( n ) : for j in range ( i , n ) : col_arr . append ( count ) row_arr . append ( ( ( j * n ) + i ) ) val_arr . append ( 1.0 ) if ( i != j ) : col_arr . append ( count ) row_arr . append ( ( ( i * n ) + j ) ) val_arr . append ( 1.0 ) count += 1 return sp . coo_matrix ( ( val_arr , ( row_arr , col_arr ) ) , ( ( n * n ) , entries ) ) . tocsc ( )
returns a coefficient matrix to create a symmetric matrix .