I'd like it to have the performance characteristics and include most of methods of Array[Double] but have additional extension methods such as dotProduct(), +, -, etc. I can write the additional extension methods but need help on the implementation of the existing traits and the measures needed to get Array like performance.
class Vec(private val content:Array[Double]) extends WrappedArray[Double] {
/* Trait implementation methods - incomplete */
def array = content
def apply(i:Int) = content(i)
def length = content.length
def update(i:Int, v:Double) = content.update(i, v)
def elemTag = ???
/* Example extension methods */
def plus(that:Vec) = Vec(this.indices.map{ i => this(i) + that(i)})
def elementProduct(that:Vec) = Vec(this.indices.map{ i => this(i) * that(i)})
def sum = content.sum
def dotProduct(that:Vec) = elementProduct(that).sum
}
object Vec {
def apply(seq:IndexedSeq[Double]) = new Vec(seq.toArray)
}