Examples of ArrayDescriptor


Examples of org.formulacompiler.compiler.internal.expressions.ArrayDescriptor

      final CellIndex from = _range.getFrom();
      final CellIndex to = _range.getTo();
      final int sheets = to.getSheetIndex() - from.getSheetIndex() + 1;
      final int rows = to.getRowIndex() - from.getRowIndex() + 1;
      final int cols = to.getColumnIndex() - from.getColumnIndex() + 1;
      final ExpressionNode result = new ExpressionNodeForArrayReference( new ArrayDescriptor( from.getSheetIndex(),
          from.getRowIndex(), from.getColumnIndex(), sheets, rows, cols ) );
      buildExpressionModelsForLocalRangeCells( _range, result.arguments() );
      return result;
    }
View Full Code Here

Examples of org.formulacompiler.compiler.internal.expressions.ArrayDescriptor

  }


  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
          .numberOfColumns(), 1 ) );
      final ExpressionNodeForArrayReference newVector = new ExpressionNodeForArrayReference( newDesc );
      newVector.arguments().addAll( _vector.arguments() );
      return newVector;
    }
View Full Code Here

Examples of org.formulacompiler.compiler.internal.expressions.ArrayDescriptor

  private ExpressionNodeForArrayReference vectorsToMatrix( ExpressionNodeForArrayReference... _vectors )
  {
    final int rows = _vectors[ 0 ].arguments().size();
    final int cols = _vectors.length;
    final ArrayDescriptor desc = new ArrayDescriptor( 1, rows, cols );
    final ExpressionNodeForArrayReference result = new ExpressionNodeForArrayReference( desc );

    for (int row = 0; row < rows; row++)
      for (int col = 0; col < cols; col++)
        result.addArgument( _vectors[ col ].argument( row ) );
View Full Code Here

Examples of org.formulacompiler.compiler.internal.expressions.ArrayDescriptor

  {
    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,
              DataType.NUMERIC ), cst( colsY, DataType.NUMERIC ), cst( rowsY, DataType.NUMERIC ) );
        }
        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

Examples of org.formulacompiler.compiler.internal.expressions.ArrayDescriptor


  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;
      index = rows;
View Full Code Here

Examples of org.formulacompiler.compiler.internal.expressions.ArrayDescriptor

      final String matchRefName = "x";
      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

Examples of org.formulacompiler.compiler.internal.expressions.ArrayDescriptor

    }
  }

  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

Examples of org.formulacompiler.compiler.internal.expressions.ArrayDescriptor

  }


  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.
    TypeAnnotator.annotateExpr( this.table );

    final List<ExpressionNode> tableElements = this.table.arguments();
    final List<String> tableLabels = getLabelsFromTable( tableDescriptor, tableElements );
    final List<ExpressionNode> dataElements = stripLabelsFromTable( tableDescriptor, tableElements );
    final List<CellModel> firstRow = getFirstRowFromTable( tableDescriptor, dataElements );
    final DataType[] colTypes = getColTypesFromFirstRow( firstRow );
    final int[] foldableColumnKeys = getFoldableColumnKeys( colTypes );
    final ExpressionNode data = getShapedDataFromTable( tableDescriptor, dataElements );

    final ArrayDescriptor critDescriptor = this.criteria.arrayDescriptor();
    final List<ExpressionNode> critElements = this.criteria.arguments();
    final List<String> critLabels = getLabelsFromTable( critDescriptor, critElements );
    final List<ExpressionNode> critData = stripLabelsFromTable( critDescriptor, critElements );
    final int[] critCols = associateCriteriaColumnsWithTableLabels( tableLabels, critLabels );
View Full Code Here

Examples of org.formulacompiler.compiler.internal.expressions.ArrayDescriptor

  {
    final Iterator<ExpressionNode> iElt = _tableElements.iterator();
    final ExpressionNode first = iElt.next();
    if (first instanceof ExpressionNodeForArrayReference) {
      final ExpressionNodeForArrayReference firstArr = (ExpressionNodeForArrayReference) first;
      final ArrayDescriptor firstArrDesc = firstArr.arrayDescriptor();
      final int firstArrRows = firstArrDesc.numberOfRows();
      if (firstArrRows > 1) {
        final ExpressionNodeForArrayReference newFirstArr = new ExpressionNodeForArrayReference(
            new ArrayDescriptor( firstArrDesc, +0, 0, -1, 0 ) );
        stripLabelsFromTableInto( firstArrDesc, firstArr.arguments(), newFirstArr.arguments() );
        _result.add( newFirstArr );
      }
    }
    else {
View Full Code Here

Examples of org.formulacompiler.compiler.internal.expressions.ArrayDescriptor


  private ExpressionNodeForArrayReference getShapedDataFromTable( ArrayDescriptor _tableDesc,
      List<ExpressionNode> _tableElements )
  {
    final ArrayDescriptor dd = new ArrayDescriptor( _tableDesc, +1, 0, -1, 0 );
    final ExpressionNodeForArrayReference result = new ExpressionNodeForArrayReference( dd );
    result.arguments().addAll( _tableElements );
    return result;
  }
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.