<commit_before>package BIDMat
import scala.math.Numeric._
import java.util.Arrays
import java.util.Comparator
import scala.actors._
import scala.actors.Actor._

class DenseMat[@specialized(Double,Float,Int,Byte) T]
(nr: Int, nc: Int, val data:Array[T])(implicit manifest:ClassManifest[T]) extends Mat(nr, nc) {
  
  def this(nr:Int, nc:Int)(implicit manifest:ClassManifest[T]) = this(nr, nc, new Array[T](nr*nc))

  /*
   * Return the (0,0) value as a scalar
   */
  def v:T =
    if (nrows > 1 || ncols > 1) {
      throw new RuntimeException("Matrix should be 1x1 to extract value")
    } else {
      data(0)
    }
  
  override def mytype = "DenseMat"
  /*
   * Test if this matrix is a row or column vector
   */
  def isvector(): Boolean = {
    if (nrows == 1 || ncols == 1) {
      true
    } else {
      false
    }
  }
  /*
   * Bounds-checked matrix access, 0- or 1-based 
   */ 
  def apply(r0:Int, c0:Int):T = {
    val off = Mat.oneBased
    val r = r0 - off
    val c = c0 - off
    if (r < 0 || r >= nrows || c < 0 || c >= ncols) {
      throw new IndexOutOfBoundsException("("+(r+off)+","+(c+off)+") vs ("+nrows+","+ncols+")");
    } else {
    	data(r+c*nrows)
    }
  }
  /*
   * Bounds-checked linear access, 0- or 1-based 
   */ 
  def apply(i0:Int):T = {
    val off = Mat.oneBased
    val i = i0 - off
    if (i < 0 || i >= length) {
      throw new IndexOutOfBoundsException(""+(i+off)+" >= ("+length+")");
    } else {
      data(i)
    }
  } 
  /*
   * Unchecked 0-based matrix access
   */ 
  def get_(r:Int, c:Int):T = {
    data(r+c*nrows)
  }
  
  /*
   * Update a matrix value, m(r,c) = v, 0- or 1-based 
   */
  def update(r0:Int, c0:Int, v:T):T = {
    val off = Mat.oneBased<commit_msg>added indexOf to DenseMat<commit_after>package BIDMat
import scala.math.Numeric._
import java.util.Arrays
import java.util.Comparator
import scala.actors._
import scala.actors.Actor._

class DenseMat[@specialized(Double,Float,Int,Byte) T]
(nr: Int, nc: Int, val data:Array[T])(implicit manifest:ClassManifest[T]) extends Mat(nr, nc) {
  
  def this(nr:Int, nc:Int)(implicit manifest:ClassManifest[T]) = this(nr, nc, new Array[T](nr*nc))

  /*
   * Return the (0,0) value as a scalar
   */
  def v:T =
    if (nrows > 1 || ncols > 1) {
      throw new RuntimeException("Matrix should be 1x1 to extract value")
    } else {
      data(0)
    }
  
  override def mytype = "DenseMat"
  /*
   * Test if this matrix is a row or column vector
   */
  def isvector(): Boolean = {
    if (nrows == 1 || ncols == 1) {
      true
    } else {
      false
    }
  }
  /*
   * Bounds-checked matrix access, 0- or 1-based 
   */ 
  def apply(r0:Int, c0:Int):T = {
    val off = Mat.oneBased
    val r = r0 - off
    val c = c0 - off
    if (r < 0 || r >= nrows || c < 0 || c >= ncols) {
      throw new IndexOutOfBoundsException("("+(r+off)+","+(c+off)+") vs ("+nrows+","+ncols+")");
    } else {
    	data(r+c*nrows)
    }
  }
  /*
   * Bounds-checked linear access, 0- or 1-based 
   */ 
  def apply(i0:Int):T = {
    val off = Mat.oneBased
    val i = i0 - off
    if (i < 0 || i >= length) {
      throw new IndexOutOfBoundsException(""+(i+off)+" >= ("+length+")");
    } else {
      data(i)
    }
  } 
  /*
   * Unchecked 0-based matrix access
   */ 
  def get_(r:Int, c:Int):T = {
    data(r+c*nrows)
  }
  
  def indexOf(a:T):Int = {
    data.indexOf(a) + Mat.oneBased
  }
  
  def indexOf2(a:T):(Int, Int) = {
    val off = Mat.oneBased
    val v = data.indexOf(a)
    (v % nrows + off, v / nrows + off)
  }
  
  /*
   * Update a matrix value, m(r,c) = v, 0- or 1-based 
   */
  def update(r0:Int, c0:Int, v:T):T = {
    val off = Mat.oneBased
{'fraction_non_alphanumeric': 0.16753211259907078, 'fraction_numerical': 0.015031429352282044, 'mean_word_length': 2.423760523854069, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4135535', 'n_tokens_mistral': 1472, 'n_tokens_neox': 1429, 'n_words': 359}