⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functionmeasure.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
字号:
/*
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/**
 * <p>Title: XELOPES</p>
 * <p>Description: Java Data Mining API. Supported standarts: <a href="http://www.dmg.org">Predictive Model Markup Language (PMML 2.0) </a>;  <a href="http://www.omg.org/cwm">DataMining specification for Common Warehouse Metamodel (OMG)</a>.</p>
 * <p>Copyright: Copyright (c) 2002-2004 prudsys AG</p>
 * <p>Company: prudsys, ZSoft</p>
 * @authorv Michael Thess
 * @version 1.2
 */

package com.prudsys.pdm.Olap.Metadata.Measures;

import javax.olap.OLAPException;

import com.prudsys.pdm.Olap.Metadata.Measure;

/**
 * Measure which applies function to other measure.
 */
public class FunctionMeasure extends Measure
{
  // -----------------------------------------------------------------------
  //  Constants declarations
  // -----------------------------------------------------------------------
  /** Absolute value. */
  public static final int ABS = 0;

  /** Closest integer to value. */
  public static final int ROUND = 1;

  /** Square value. */
  public static final int SQR = 2;

  /** Square root of value. */
  public static final int SQRT = 3;

  /** E raised to power of value. */
  public static final int EXP = 4;

  /** Natural logarithmus of value. */
  public static final int LOG = 5;

  /** Sinus of value. */
  public static final int SIN = 6;

  /** Cosinus of value. */
  public static final int COS = 7;

  /** Tangens of value. */
  public static final int TAN = 8;

  /** Arc sinus of value. */
  public static final int ASIN = 9;

  /** Arc cosinus of value. */
  public static final int ACOS = 10;

  /** Arc tangens of value. */
  public static final int ATAN = 11;

  // -----------------------------------------------------------------------
  //  Variables declarations
  // -----------------------------------------------------------------------
  /** Measure used as function argument. */
  protected Measure measure;

  // -----------------------------------------------------------------------
  //  Constructor
  // -----------------------------------------------------------------------
  /**
   * Empty constructor.
   */
  public FunctionMeasure() {
  }

  /**
   * Constructor with given subtype and argument measure.
   *
   * @param subtype measure subtype
   * @param measure argument measure
   */
  public FunctionMeasure(int subtype, Measure measure) {

    this.subtype = subtype;
    this.measure = measure;
  }

  // -----------------------------------------------------------------------
  //  Getter and setter methods
  // -----------------------------------------------------------------------
  /**
   * Returns argument measure.
   *
   * @return argument measure
   */
  public Measure getMeasure() {
    return measure;
  }

  /**
   * Sets new argument measure.
   *
   * @param measure new argument measure.
   */
  public void setMeasure(Measure measure) {
    this.measure = measure;
  }

  // -----------------------------------------------------------------------
  //  Method of measure value calculation
  // -----------------------------------------------------------------------
  /**
   * Calculates function measure value.
   *
   * @return measure value
   * @throws OLAPException unknwn subtype
   */
  public double measureValue() throws OLAPException {

    double value = measure.measureValue();

    if (subtype == ABS)
      return Math.abs(value);
    else if (subtype == ROUND)
      return Math.round(value);
    else if (subtype == SQR)
      return value*value;
    else if (subtype == SQRT)
      return Math.sqrt(value);
    else if (subtype == EXP)
      return Math.exp(value);
    else if (subtype == LOG)
      return Math.log(value);
    else if (subtype == SIN)
      return Math.sin(value);
    else if (subtype == COS)
      return Math.cos(value);
    else if (subtype == TAN)
      return Math.tan(value);
    else if (subtype == ASIN)
      return Math.asin(value);
    else if (subtype == ACOS)
      return Math.acos(value);
    else if (subtype == ATAN)
      return Math.atan(value);

    else
      throw new OLAPException("unknown subtype");
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -