This is the code that uses sparse matrices:

for i = 1:n
        for j = i:n
           if i == j
                sp = start'*sparse([i,n+i,2n+1],[i,n+i,2n+1],[1,1,-1])
                lhs[rctr,:] = -2*sp -2*radii[i]*c
                rhs[rctr] = -(sp*start)[1]   -radii[i]^2 
               
            else
                sp = 
start'*sparse([i,j,n+i,n+j,i,j,n+i,n+j],[i,j,n+i,n+j,j,i,n+j,n+i],[1,1,1,1,-1,-1,-1,-1],2n+1,2n+1)
                lhs[rctr,:] = 2*sp
                rhs[rctr] = (sp*start)[1] + ( radii[i]+radii[j] )^2 
            end
            rctr += 1
        end
    end

With 4th rank sparse matrices, I could define them outside the loop.  





On Saturday, September 12, 2015 at 12:09:11 PM UTC-4, Frank Kampas wrote:
>
> Is it possible to create sparse matrices with a rank other than 2?
>

Reply via email to