2016-03-31 7 views
1

Scalaアプリケーション用の高性能線形代数ライブラリとして、Scala Breezeが見つかりました。Scala Breeze:Int配列要素のDenseMatrixを作成できますか?

要素配列としてInt配列を持つDenseMatrixを初期化する方法があるのだろうかと思います。

これは私がブリーズに移植しようとしていますOpenCVの機能は次のとおりです。

val rgb_raw = Array[Byte] (....) //ByteArray RGB values dim 480x360 
val rgb_mat = new Mat (360, 480, CvType.CV_8UC3) 
rgb_mat.put(0,0,rgb_raw) 

私はそれが同じように簡単なものでしたい:

val rgb_mat = new DenseMatrix(360,480, rgb_raw) 

または

val rgb_mat = new DenseMatrix[Array[Int,Int,Int]](360,480,rgb_raw) 

I避難所私が正しい方向に向いていることをドキュメント内に見いだしました。

答えて

0

これは私のため

import breeze.linalg.DenseMatrix 

val range = 0 to 360*480 

val arr = range map(_=>0.toByte)).toArray 

new DenseMatrix(360,480, arr) 

res27: breeze.linalg.DenseMatrix[Byte] = 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... (480 total) 

new DenseMatrix(360,480, range.toArray) 

res28: breeze.linalg.DenseMatrix[Int] = 
0 360 720 1080 1440 1800 2160 2520 2880 3240 3600 ... (480 total) 

val arrr = range.map(_=>arr).toArray 

new DenseMatrix(360,480, arrr) 

res31: breeze.linalg.DenseMatrix[Array[Byte]] = 
[[email protected] [[email protected] [[email protected] [[email protected] ... (480 total) 
の作品
関連する問題