0

In relation to the answer of NOAH on how to use CSCMatrix

how to construct matrix B, it consists of what items?

Community
  • 1
  • 1
Francois Saab
  • 77
  • 1
  • 9

1 Answers1

0

It looks like CSC matrices only support B columns in the form of a DenseVector:

scala> import breeze.linalg._
import breeze.linalg._

scala> import breeze.numerics._
import breeze.numerics._

scala> val A = CSCMatrix((1d,0d,0d),(0d,1d,0d),(0d,0d,1d))
A: breeze.linalg.CSCMatrix[Double] =
3 x 3 CSCMatrix
(0,0) 1.0
(1,1) 1.0
(2,2) 1.0

scala> val B = DenseVector(3d,4d,5d)
B: breeze.linalg.DenseVector[Double] = DenseVector(3.0, 4.0, 5.0)

scala> A \ B
res0: breeze.linalg.DenseVector[Double] = DenseVector(3.000000000000001, 4.000000000000002, 5.000000000000001)
evan.oman
  • 5,922
  • 22
  • 43
  • :you have right from Api point of view but my problem is that this code is not compiling. am getting the following : Error:(44, 9) could not find implicit value for parameter op: breeze.linalg.operators.OpSolveMatrixBy.Impl2[breeze.linalg.CSCMatrix[Double],breeze.linalg.DenseVector[Double],That] A \ B ^ Error:(44, 9) not enough arguments for method \: (implicit op: breeze.linalg.operators.OpSolveMatrixBy.Impl2[breeze.linalg.CSCMatrix[Double],breeze.linalg.DenseVector[Double],That])That. Unspecified value parameter op. A \ B ^ – Francois Saab Dec 02 '16 at 18:01
  • Hmm, so using a `DenseVector` for your `B` isn't working? What version of Breeze are you using? – evan.oman Dec 02 '16 at 19:03
  • if i look in intellijidea : it is breeze-macros_2.10-0.11.2.jar – Francois Saab Dec 02 '16 at 19:16
  • yes A works if i give it another sparse matrix. like A/B B needs to be a sparse matrix of same size with A. i dont understand why? but if so i am asking here a mathematical question how to construct the matrix B to contain the values of a vector b. – Francois Saab Dec 02 '16 at 19:21