Dvector.java
Upload User: rhdiban
Upload Date: 2013-08-09
Package Size: 15085k
Code Size: 2k
Category:

Windows Develop

Development Platform:

Java

  1. /*
  2.  *    This program is free software; you can redistribute it and/or modify
  3.  *    it under the terms of the GNU General Public License as published by
  4.  *    the Free Software Foundation; either version 2 of the License, or
  5.  *    (at your option) any later version.
  6.  *
  7.  *    This program is distributed in the hope that it will be useful,
  8.  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.  *    GNU General Public License for more details.
  11.  *
  12.  *    You should have received a copy of the GNU General Public License
  13.  *    along with this program; if not, write to the Free Software
  14.  *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15.  */
  16. /*
  17.  *    Dvector.java
  18.  *    Copyright (C) 1999 Yong Wang
  19.  *
  20.  */
  21. package weka.classifiers.m5;
  22. import java.io.*;
  23. import java.util.*;
  24. import weka.core.*;
  25. /**
  26.  * Class for handling a double vector.
  27.  * @author Yong Wang (yongwang@cs.waikato.ac.nz)
  28.  * @version $Revision: 1.4 $
  29.  */
  30. public final class Dvector {
  31.   /**
  32.    * Returns a copy of the first n elements of a double vector
  33.    * @param a a double vector
  34.    * @param n a[0:n-1] will be copied
  35.    * @return a copy of a[0:n-1]
  36.    */
  37.   public static final double[]  copy(double a[],int n) {
  38.     int i;
  39.     double b[];
  40.     
  41.     b = new double[n];
  42.     for(i=0;i<n;i++)b[i]=a[i];
  43.     return b;
  44.   }
  45.   
  46.   /**
  47.    * Prints the indexed elements in a double vector
  48.    * @param a a double vector
  49.    * @param first the index of the first instance for printing
  50.    * @param last the index of the last instance for printing
  51.    */
  52.   public static final void  print(double []a,int first,int last){
  53.     
  54.     int i;
  55.     System.out.println("Print double vector:");
  56.     for(i=first;i<=last;i++)System.out.print("t" + M5Utils.doubleToStringG(a[i],1,3));
  57.     System.out.println();
  58.   }
  59. }