Package org.formulacompiler.compiler.internal.expressions

Examples of org.formulacompiler.compiler.internal.expressions.ArrayDescriptor.numberOfColumns()


    final int iRow = valueToIntOrOne( _rowIndex ) - 1;
    final int iCol = valueToIntOrOne( _colIndex ) - 1;
    int iValue;
    if (iRow < 0 || iRow >= desc.numberOfRows())
      throw new FormulaException( "#VALUE/REF! because row out of range in INDEX" );
    if (iCol < 0 || iCol >= desc.numberOfColumns())
      throw new FormulaException( "#VALUE/REF! because column out of range in INDEX" );
    if (null != _rowIndex && null != _colIndex) {
      iValue = iRow * desc.numberOfColumns() + iCol;
    }
    else {
View Full Code Here


    if (iRow < 0 || iRow >= desc.numberOfRows())
      throw new FormulaException( "#VALUE/REF! because row out of range in INDEX" );
    if (iCol < 0 || iCol >= desc.numberOfColumns())
      throw new FormulaException( "#VALUE/REF! because column out of range in INDEX" );
    if (null != _rowIndex && null != _colIndex) {
      iValue = iRow * desc.numberOfColumns() + iCol;
    }
    else {
      iValue = iRow + iCol;
    }
    return ((ExpressionNodeForConstantValue) _range.argument( iValue )).value();
View Full Code Here

  private ExpressionNodeForArrayReference makeVertical( ExpressionNodeForArrayReference _vector )
  {
    final ArrayDescriptor desc = _vector.arrayDescriptor();
    assert desc.numberOfSheets() == 1;
    if (desc.numberOfRows() > 1) {
      assert desc.numberOfColumns() == 1;
      return _vector;
    }
    else {
      assert desc.numberOfRows() == 1;
      final ArrayDescriptor newDesc = new ArrayDescriptor( desc.origin(), new ArrayDescriptor.Point( 1, desc
View Full Code Here

    switch (_fun.getFunction()) {

      case CHITEST: {
        if (_fun.cardinality() < 6) {
          final ArrayDescriptor descX = ((ExpressionNodeForArrayReference) _fun.argument( 0 )).arrayDescriptor();
          final int colsX = descX.numberOfColumns();
          final int rowsX = descX.numberOfRows();
          final ArrayDescriptor descY = ((ExpressionNodeForArrayReference) _fun.argument( 1 )).arrayDescriptor();
          final int colsY = descY.numberOfColumns();
          final int rowsY = descY.numberOfRows();
          return fun( CHITEST, _fun.argument( 0 ), _fun.argument( 1 ), cst( colsX, DataType.NUMERIC ), cst( rowsX,
View Full Code Here

        if (_fun.cardinality() < 6) {
          final ArrayDescriptor descX = ((ExpressionNodeForArrayReference) _fun.argument( 0 )).arrayDescriptor();
          final int colsX = descX.numberOfColumns();
          final int rowsX = descX.numberOfRows();
          final ArrayDescriptor descY = ((ExpressionNodeForArrayReference) _fun.argument( 1 )).arrayDescriptor();
          final int colsY = descY.numberOfColumns();
          final int rowsY = descY.numberOfRows();
          return fun( CHITEST, _fun.argument( 0 ), _fun.argument( 1 ), cst( colsX, DataType.NUMERIC ), cst( rowsX,
              DataType.NUMERIC ), cst( colsY, DataType.NUMERIC ), cst( rowsY, DataType.NUMERIC ) );
        }
        break;
View Full Code Here

        break;
      }
      case MDETERM: {
        if (_fun.cardinality() < 2) {
          final ArrayDescriptor desc = ((ExpressionNodeForArrayReference) _fun.argument( 0 )).arrayDescriptor();
          final int cols = desc.numberOfColumns();
          final int rows = desc.numberOfRows();
          if (cols != rows) {
            throw new CompilerException.UnsupportedExpression( "MDETERM called with non-square matrix" );
          }
          return fun( MDETERM, _fun.argument( 0 ), cst( cols, DataType.NUMERIC ) );
View Full Code Here

  private ExpressionNode rewriteArrayLookup( ExpressionNodeForFunction _fun )
  {
    final ExpressionNodeForArrayReference array = (ExpressionNodeForArrayReference) _fun.argument( 1 );
    final ArrayDescriptor desc = array.arrayDescriptor();
    final int cols = desc.numberOfColumns();
    final int rows = desc.numberOfRows();
    final Function lookupFun;
    final int index;
    if (cols > rows) {
      lookupFun = HLOOKUP;
View Full Code Here

      final ExpressionNode matchRefNode = var( matchRefName );
      final ExpressionNode selectorNode = indexNode;
      final ExpressionNode defaultNode = err( "#VALUE/REF! because index is out of range in H/VLOOKUP" );

      final ArrayDescriptor desc = arrayNode.arrayDescriptor();
      final int nArrays = (fun == HLOOKUP) ? desc.numberOfRows() : desc.numberOfColumns();
      final ExpressionNodeForSwitchCase[] caseNodes = new ExpressionNodeForSwitchCase[ nArrays ];
      for (int iArray = 0; iArray < nArrays; iArray++) {
        final ExpressionNode valueArrayNode = getHVLookupSubArray( fun, arrayNode, iArray );
        final ExpressionNode lookupNode = fun( INDEX, valueArrayNode, matchRefNode );
        caseNodes[ iArray ] = new ExpressionNodeForSwitchCase( lookupNode, iArray + 1 );
View Full Code Here

  private ExpressionNode getHVLookupSubArray( Function _fun, ExpressionNodeForArrayReference _arrayNode, int _index )
  {
    final ArrayDescriptor desc = _arrayNode.arrayDescriptor();
    if (_fun == HLOOKUP) {
      final int cols = desc.numberOfColumns();
      return _arrayNode.subArray( _index, 1, 0, cols );
    }
    else {
      final int rows = desc.numberOfRows();
      return _arrayNode.subArray( 0, rows, _index, 1 );
View Full Code Here


  public final ExpressionNode rewrite() throws CompilerException
  {
    final ArrayDescriptor tableDescriptor = this.table.arrayDescriptor();
    if (tableDescriptor.numberOfColumns() == ArrayDescriptor.DYNAMIC) {
      throw new CompilerException.SectionOrientation( "The function "
          + this.fun.getFunction() + " can only operate on vertically repeating sections." );
    }

    // We need the type info to properly treat by-example criteria contained in strings.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.