Simple Graphing Calculator with 2D array

Hello,
I am building a simple graphing calculator which reads in coefficients from a txt file. All is going well except when I plot the points, the graph is at the corner of the screen and sideways. As we all know, the origin of the array is at the top right corner, so how do I transform/slide it so that it is at the xy origin? Code is posted below, thanks!
import javax.swing.*;
import java.awt.*;
public class baseClass extends JFrame{
     private shapesPanel panel;
     public baseClass(String title){
          panel = new shapesPanel();
          setTitle(title);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          getContentPane().add(panel);
          pack();
          setVisible(true);
     public void drawLine(int x1, int y1, int x2, int y2){
          panel.addLine((short)x1,(short)y1,(short)x2,(short)y2);
          panel.repaint();
     public void drawDot(int x, int y){
          panel.addOval((short)x,(short)y,(short)1,(short)1);
          panel.repaint();
     private class shapesPanel extends JPanel{
          final private short max = 10000;
          private short[][] lines, ovals;
          private int numLines, numOvals;
          public shapesPanel(){
               setBackground(Color.white);
               setPreferredSize (new Dimension(500,500));
               lines = new short[max][4];
               ovals = new short[max][4];
               numLines = 0;
               numOvals = 0;
          public void paintComponent(Graphics g){
               super.paintComponent(g);
               g.setColor(new Color(0,0,255));
               for(int i = 0; i < numLines;++i){
                    g.drawLine(lines[0],lines[i][1],lines[i][2],lines[i][3]);
               g.setColor(new Color(255,0,0));
               for(int i = 0; i < numOvals;++i){
                    g.drawOval(ovals[i][0],ovals[i][1],ovals[i][2],ovals[i][3]);
          public void addLine(short x1, short y1, short x2, short y2){
               lines[numLines][0] = x1;
               lines[numLines][1] = y1;
               lines[numLines][2] = x2;
               lines[numLines][3] = y2;
               ++numLines;
          public void addOval(short x, short y, short w, short h){
               ovals[numOvals][0] = x;
               ovals[numOvals][1] = y;
               ovals[numOvals][2] = w;
               ovals[numOvals][3] = h;
               ++numOvals;
import java.util.Scanner;
import java.io.*;
public class graphingCalculator extends baseClass{
     // CONTAINS THE FOUR FUNCTION COEFFICIENTS
     private double[] theFunction;
// CONTAINS THE DISCRETE FUNCTION PLOT
private boolean[][] grid;
// SIZE OF THE COORDINATE SYSTEM
private final int columns = 500, rows = 500;
public graphingCalculator(String filename) throws IOException{
     // INITIALIZATIONS ///////////////////////////////////////
super("GRAPHING CALCULATOR");
theFunction = new double[4];
     grid = new boolean[rows][columns];
for(int i = 0;i<rows;++i){
for(int j = 0;j<columns;++j){
grid[i][j] = false;
// DRAW THE COORDINATE SYSTEM ON THE SCREEN /////////////
drawLine(0,250,500,250);
drawLine(250,0,250,500);
for(int i = 0; i < columns;i+=20){
drawLine(i,247,i,253);
for(int i = 0; i < rows;i+=20){
drawLine(247,i,253,i);
// GET THE FUNCTION COEFFICIENTS ///////////////////////
// theFunction[0] will have the x^3 coefficient
// theFunction[1] will have the x^2 coefficient
// theFunction[2] will have the x^1 coefficient
// theFunction[3] will have the x^0 coefficient
Scanner scan1 = new Scanner(new File(filename));
for(int i=0;i<4;++i){
     theFunction[i] = scan1.nextDouble();
scan1.close();
// DRAW THE FUNCTION ////////////////////////////////////
computeGrid();
drawDiscrete();
drawContinuous();
private double computeFunction(int x)
     double a=theFunction[0];
     double b=theFunction[1];
     double c=theFunction[2];
     double d=theFunction[3];
     double answer=(a*Math.pow(x,3.0)+b*Math.pow(x,2.0)+c*Math.pow(x,1.0)+d*Math.pow(x,0.0));
     return answer;
private void computeGrid()
          // Populate the 'grid' array with true values that correspond
          // to the discrete function.
          // The 'grid' array is the internal representation of the function
     for(int x=0; x<columns; x++)
               if(computeFunction(x)>=0&&computeFunction(x)<500)
               grid[(int)computeFunction(x)][x]=true;
private void drawDiscrete()
          // Use drawDot(x,y) to draw the discrete version of the function
     for(int x=0;x<columns;x++)
          for(int j=0;j<rows;j++)
     if(grid[x][j])
          drawDot(x,j);
private void drawContinuous()
          // Use drawLine(x1,y1,x2,y2) to draw the continuous version of the function

Rest of code:
import java.util.Scanner;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
    String infile;
    Scanner scan = new Scanner(System.in);
    // The input file should have 4 doubles in it
    // corresponding to the 4 coefficients of a cubic function.
    // A GOOD EXAMPLE:
    //                  0.01
    //                  0.0
    //                  -5.0
    //                          50.0
    // CORRESPONDS TO FUNCTION: 0.01*X^3 - 5.0*X + 50.0       
    // ANOTHER GOOD EXAMPLE:
    //                  0.0
    //                  0.01
    //                  -1.0
    //                          -100.0
    // CORRESPONDS TO FUNCTION: 0.01*X^2 - X - 100.0       
    System.out.println("Please enter filename of input file: ");
    infile = scan.next();
    graphingCalculator cal = new graphingCalculator(infile);
}

Similar Messages

  • How do I make a continuous X-Y graph with an array as input?

    I want to create an X-Y graph with a reference time (double) as one variable and the other is a double data type. How can I create a continuous graph on an X-Y graph with these variables? I have only been using Labview for 2 months so if you have any suggestions please go easy on the technical terms.
    TIA,
    Kevin

    LabVIEW what several options for displaying data. A waveform chart is great if you receive one point at a time and want to plot the data in series. A waveform graph is good for plotting arrays in a time series fashion. An xy plot is good for connecting points that do not occur in a series. This plot offers the most flexibility in graphing points with different x values.
    It is often hard to keep what structure goes two what display option. As a cheat, I right click on the chart in the block diagram and slide the mouse to create >> (either a constant or control). This way you can get a model for the data you want to input.
    You may also want to look at the shipping examples that come with LabVIEW. In LabVIEW 6.1, goto help >> find examples >> fundamen
    tals >> graphs and charts.
    Jeremy Braden
    National Instruments

  • How Do You Populate A Spark List Control With An Array?

    Hello, all,
    Sorry to come accross so frustrated, but how in the name of God do you populate a Spark list control with the data in an array?  You used to be able to do this with the mx:List control, but the guys developing Flex just had to make things more difficult than they need to be!  I am more of a code purist and prefer doing things the way they have been done for decades, but apparently nothing can ever stay simple!
    I simply want to populate a list control with an array and this shouldn't be rocket science!  I found out that I must use a "collection" element, so I decided that an arrayCollection would be best.  However, after searching Adobe's documentation about arrayCollections, I am lost in a black hole of data binding, extra lines of code just to add a new element, the need to sort it, etc...!
    Here is my code:
    var pendingArray:ArrayCollection = new ArrayCollection();
    for ( var i:int = 0 ; i < queue.length ; i++ )
         var item:UserQueueItem = queue[i] as UserQueueItem ;
         if ( item.status == UserQueueItem.STATUS_PENDING )
         pendingArray.addItem({label:item.descriptor.displayName,descriptor:item.descriptor});
    Here is the relevant MXML:
    <s:VGroup>
         <s:List id="knockingList" width="110" height="100"/>              
    </s:VGroup>
    I'm not getting any errors, but the list is not populating.
    I have seen several examples where the arrayCollection is declared and populated in MXML:
            <mx:ArrayCollection id="myAC">
                <!-- Use an fx:Array tag to associate an id with the array. -->
                <fx:Array id="myArray">
                    <fx:Object label="MI" data="Lansing"/>
                    <fx:Object label="MO" data="Jefferson City"/>
                    <fx:Object label="MA" data="Boston"/>
                    etc...
               </fx:Array>
            </mx:ArrayCollection>
    That may be fine for an example, but I think this is a rare situation.  Most of the time I would image that the arrayCollection would be created and populated on the fly in ActionScript!  How can I do this?
    Thanks in advance for any help or advice anyone can give!
    Matt

    In your post it seemed like you were trying to take care of many considerations at once: optimization, design, architecture.  I would suggest you get something up and running and then worry about everything else.
    If I use data binding, then I will probably have to declare the  arrayCollection as a global variable and then I'll have to write 100 or  so extra lines of code to addItem(), removeItem(), sort(), etc...  It  just seems like too much overhead.
    I believe you may have some misconceptions about databinding in general.  You won't have to make it a global variable and you certainly won't need an extra 100 lines of code.  If you did this forum would be a very , very quiet place.
    I don't want to use data binding because the original array is refreshed  often and there is one function called by an event that re-declares the  arrayCollection each time, populates it with the array, and then sets  it as the list's dataprovider.
    That is the beauty of the ArrayCollection, it can handle the updates to its source Array. I don't know if you need to redeclare the ArrayCollection, resetting the source to the new Array allows everyone involved to keep their references so you don't have to worry about any "spooky" stuff going on.

  • I am using Numbers on my iPhone5 and cannot get the app to do a simple (SUM) calculation.  It shows the formula correctly in the cell, but all I get for my long list of numbers to add is 0.  How can I get this to work?

    I am using Numbers on my iPhone5 and cannot get the app to do a simple (SUM) calculation.  It shows the formula correctly in the cell, but all I get for my long list of numbers to add is 0.  How can I get this to work?

    Oaky, at least we got that far.  Next step is to determine if all those "numbers" are really numbers.  Changing the format to "number" doesn't necessarily change the string to a number. The string has to be in the form of a number.  Some may appear to you and me as numbers but will not turn into "numbers" when you change the formatting from Text to Number. Unless you've manually formatted the cells to be right justified, one way to tell if it is text or a number is the justification. Text will be justified to the left, numbers will be justified to the right.
    Here are some that will remain as strings:
    +123
    123 with a space after it.
    .123

  • Trouble with primitive arrays and casting, lesson 521

    hi everyone!
    there is a problem i discovered right now - after years with java where was no necessity to do this.....
    and i'm shure this must have been the topic already, but i couldn't find any helpful resource :-/
    right here we go:
    1. an array is a (special) kind of object.
    2. there are "primitive" arrays and such containing references to objects. of course - and i imagine why - they are treated differently by the VM.
    3. then both are - somehow - subclasses of Object. whereas primitive types are not really, primitive-arrays are. this is hidden to the programmer....
    4. any array can be "pointed" at via local Object variable, like this:
    Object xyz = new int[6];
    5. arrays of Objects (with different dimensions) can be casted, like this:
      Object pointer = null;
      Object[]   o  = new SomeClass[42] ;
      Object[][] oo = new OtherClass[23] [2] ;
      Object[][][] ooo = new OtherClass[23] [2] [9] ;
      o = oo = ooo;     // this is save to do,
                                   //because "n-dimensional" object-arrays
                                  // are just arrays of  other arrays, down to simple array
    pointer = o;         // ok, we are referencing o via Object "pointer"6. but, you cannot do this with primitive types:
      int[]  i1 = new int [99] ;
      int[][] i2 = new int [1] [3] ;
      i1 = i2                  // terror: impossible. this is awful, if you ask me.
                                   // ok, one could talk about "special cases" and
                                   // "the way the VM works", but this is not of interest to me as
                                   // a programmer. i'm not happy with that array-mess!
      pointer = i2;       // now this is completely legal. i2, i1 etc is an object!7. after the preparation, let's get into my main trouble (you have the answer, i know!) :
    suppose i have a class, with methods that should process ANY kind of object given. and - i don't know which. i only get it at runtime from an unknown source.
    let's say: public void BlackBox( Object x );
    inside, i know that there might be regular objects or arrays, and for this case i have some special hidden method, just for arrays... now try to find it out:
    public void BlackBox( Object x )
      if ( x == null)
           return;
       Class c = x.getClass();
       if ( c.isArray() )
              // call the array method if it's an array.........
              BlackBoxes(     (Object [] )  x );         // wait: this is a cast! and it WILL throw an exception, eventually!
              return;
       else
               DoSpecialStuffWith( x );
    }ok ? now, to process any kind of array, the special method you cannot reach from outside:
    private void BlackBoxes( Object[] xs )
       if ( xs != null )
            for ( Object x : xs )
                 BlackBox( x );
    // this will end up in some kind of recursion with more than one array-dimension, or when an Object[] has any other array as element!this approach is perfectly save when processing any (real) Object, array or "multi-dimensional" arrays of Objects.
    but, you cannot use this with primitive type arrays.
    using generics wouldn't help, because internally it is all downcasted to Object.
    BlackBox( new Integer(3) ) ---- does work, using a wrapper class
    BlackBox( new Integer[3] ) ----- yep!
    BlackBox( 3 ) ---- even this!
    BlackBox( new int[42] ) ---- bang! ClassCastException, Object[] != int[]
    i'm stuck. i see no way to do this smoothly. i could write thousands of methods for each primitive array - BlackBox( int[] is ) etc. - but this wouldn't help. because i can't cast an int[][] to int[], i would also have to write countless methods for each dimension. and guess, how much there are?
    suppose, i ultimately wrote thousands of possible primitive-type methods. it would be easy to undergo any of it, writing this:
    BlackBox( (Object) new int[9] [9] );
    the method-signature would again only fit to my first method, so the whole work is useless. i CAN cast an int[] to Object, but there seems no convenient way to get the real array out of Object - in a generic way.
    i wonder, how do you write a serialisation-engine? and NO, i can't rely on "right usage" of my classes, i must assume the worst case...
    any help appreciated!

    thanks, brigand!
    your code looks weird to me g and i think there's at least one false assumption: .length of a multidimensional array returns only the number of "top-level" subarrays. that means, every length of every subarray may vary. ;)
    well i guess i figured it out, in some way:
    an int is no Object;
    int[ ] is an Object
    the ComponentType of int [ ] is int
    so, the ComponentType of an Object int[ ] is no Object, thus it cannot be casted to Object.
    but the ComponentType of int [ ] [ ] IS Object, because it is int [ ] !
    so every method which expects Object[], will work fine with int[ ] [ ] !!
    now, you only need special treatment for 1-dimensional primitive arrays:
    i wrote some code, which prints me everything of everything:
        //this method generates tabs for indentation
        static String Pre( int depth)
             StringBuilder pre = new StringBuilder();
             for ( int i = 0; i < depth; i++)
                  pre.append( "\t" );
             return pre.toString();
        //top-level acces for any Object
        static void Print( Object t)
             Print ( t, 0);
        //the same, but with indentation depth
        static void Print( Object t, int depth)
            if ( t != null )
                 //be shure it is treated exactly as the class it represents, not any downcast
                 t = t.getClass().cast( t );
                if ( t.getClass().isArray() )
                     //special treatment for int[]
                     if ( t instanceof int[])
                          Print( (int[]) t, depth);
                     // everything else can be Object[] !
                     else
                          Print( (Object[]) t, depth );
                     return;
                else
                    System.out.println( Pre(depth) + " [ single object:] " + t.toString() );
            else
                System.out.println( Pre(depth) + "[null!]");
        // now top-level print for any array of Objects
        static void Print( Object [] o)
             Print( o, 0 );
        // the same with indentation
        static void Print( Object [] o, int depth)
            System.out.println( Pre(depth) + "array object " + o.toString() );
            for ( Object so : o )
                    Print( so, depth + 1 );
        //the last 2 methods are only for int[] !
        static void Print( int[] is)
             Print( is, 0 );
        static void Print( int[] is, int depth)
            System.out.println( Pre(depth) + "primitive array object " + is.toString() );
            // use the same one-Object method as every other Object!
            for ( int i : is)
                 Print ( i, depth + 1 );
            System.out.println( "-----------------------------" );
        }now, calling it with
    Print ( (int) 4 );
    Print ( new int[] {1,2,3} );
    Print( new int[][] {{1,2,3}, {4,5,6}} );
    Print( new int[][][] {{{1,2,3}, {4,5,6}} , {{7,8,9}, {10,11,12}}, {{13,14,15}, {16,17,18}} } );
    Print( (Object) (new int[][][][] {{{{99}}}} ) );
    produces this fine array-tree:
    [ single object:] 4
    primitive array object [I@9cab16
          [ single object:] 1
          [ single object:] 2
          [ single object:] 3
    array object [[I@1a46e30
         primitive array object [I@3e25a5
               [ single object:] 1
               [ single object:] 2
               [ single object:] 3
         primitive array object [I@19821f
               [ single object:] 4
               [ single object:] 5
               [ single object:] 6
    array object [[[I@addbf1
         array object [[I@42e816
              primitive array object [I@9304b1
                    [ single object:] 1
                    [ single object:] 2
                    [ single object:] 3
              primitive array object [I@190d11
                    [ single object:] 4
                    [ single object:] 5
                    [ single object:] 6
         array object [[I@a90653
              primitive array object [I@de6ced
                    [ single object:] 7
                    [ single object:] 8
                    [ single object:] 9
              primitive array object [I@c17164
                    [ single object:] 10
                    [ single object:] 11
                    [ single object:] 12
         array object [[I@1fb8ee3
              primitive array object [I@61de33
                    [ single object:] 13
                    [ single object:] 14
                    [ single object:] 15
              primitive array object [I@14318bb
                    [ single object:] 16
                    [ single object:] 17
                    [ single object:] 18
    array object [[[[I@ca0b6
         array object [[[I@10b30a7
              array object [[I@1a758cb
                   primitive array object [I@1b67f74
                         [ single object:] 99
    -----------------------------and i'll have to write 8 methods or so for every primitive[ ] type !
    sounds like a manageable effort... ;-)

  • Simple test case with NL and table order .

    Hi,
    did some tests on my 9.2.0.8 and got few questions:
    SQL> select count(*)  from p;
      COUNT(*)
          2000
    SQL> select count(*)  from c;
      COUNT(*)
          1000
    SQL> select count(*) , id from p group by id having count(*) > 1;
    no rows selected
    SQL> select count(*) , id from c group by id having count(*) > 1;
      COUNT(*)         ID
           100         10
    SQL> desc p
               Name
        1      ID number
        2      FILLER varchar2(100)
    SQL> desc c
               Name
        1      ID number
        2      FILLER varchar2(100)
    Got 10046 traces:
    case A
    select /*+ use_nl(p) leading(c) */ *
    from
    p , c where p.id = c.id and c.id in (10)
    Rows     Row Source Operation
        100  TABLE ACCESS BY INDEX ROWID P
        201   NESTED LOOPS
        100    TABLE ACCESS BY INDEX ROWID C
        100     INDEX RANGE SCAN C_ID (object id 411255)
        100    INDEX RANGE SCAN P_ID (object id 411256)
    Case B optimal
    select /*+ use_nl(c) leading(p) */ *
    from
    p , c where p.id = c.id and c.id in (10)
    Rows     Row Source Operation
        100  TABLE ACCESS BY INDEX ROWID C
        102   NESTED LOOPS
          1    TABLE ACCESS BY INDEX ROWID P
          1     INDEX RANGE SCAN P_ID (object id 411256)
        100    INDEX RANGE SCAN C_ID (object id 411255)So its simple nested loop with postponed inner table access .
    Why in row source operation we have got 102 rows (NL level) ? (It means NL was executed 102 times ?)
    And why 201 in other case ?
    Regards
    GregG

    I am not sure about the calculation/reason for those A-ROWS figures but the NL operation executes only once (but accesses inner rowsource 100 times in case one and once in second case) in both cases (which is as expected).
    A closer test case (to OP) is
    SQL> select * from v$version ;
    BANNER                                                                                                                                                                    
    Oracle Database 10g Release 10.2.0.5.0 - Production                                                                                                                       
    PL/SQL Release 10.2.0.5.0 - Production                                                                                                                                    
    CORE     10.2.0.5.0     Production                                                                                                                                                
    TNS for Linux: Version 10.2.0.5.0 - Production                                                                                                                            
    NLSRTL Version 10.2.0.5.0 - Production                                                                                                                                    
    SQL> create table p nologging as select level as id, cast(dbms_random.string('a', 100) as varchar2(100)) as filler from dual connect by level <= 2000 ;
    Table created.
    SQL> exec dbms_stats.gather_table_stats(user, 'P') ;
    PL/SQL procedure successfully completed.
    SQL> create index p_id on p(id) nologging ;
    Index created.
    SQL> select count(*)  from p;
      COUNT(*)                                                                                                                                                                
          2000                                                                                                                                                                
    SQL> select count(*) , id from p group by id having count(*) > 1;
    no rows selected
    SQL> create table c nologging as select level as id, cast(dbms_random.string('a', 100) as varchar2(100)) as filler from dual connect by level <= 900 union all select 10, cast(dbms_random.string('a', 100) as varchar2(100)) as filler from dual connect by level <= 99 ;
    Table created.
    SQL> select count(*) , id from c group by id having count(*) > 1;
      COUNT(*)         ID                                                                                                                                                     
           100         10                                                                                                                                                     
    SQL> exec dbms_stats.gather_table_stats(user, 'C') ;
    PL/SQL procedure successfully completed.
    SQL> create index c_id on c(id) nologging ;
    Index created.
    SQL> select /*+ use_nl(p) leading(c) gather_plan_statistics */ * from p , c where p.id = c.id and c.id in (10) ;
            ID FILLER                                                                                                       ID                                                
    FILLER                                                                                                                                                                    
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    zrGZSmUFXNyNMOViUYSvPDdfznSlMvaFnQakopPtcBvXQkWmMlWCnrPyeZLfhuLLeYyAEkcwZNSfoASLYpoAnpESqlQWkaEGatXV                                                                      
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    hKtrWPCfAmWWLGMXfwHCusSwVpehEnZdxYPLouIuBlMMiSKlIJWwklZCAXZaCbIxKlhzBVRhhTPdLcheyAdoYyfxwomqWRrMXuMk                                                                      
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    ncSqclZvOGgyXDPaaouGaUqXmJtFNbNyFzUalDknEMvTsBRwGmTxOCIalLvqMnuTFBZJGzNfBqaSVHUtvNDceVZqKQQyqeGKOUdz                                                                      
    100 rows selected.
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST')) ;
    PLAN_TABLE_OUTPUT                                                                                                                                                         
    SQL_ID  1f55m4rabtu3h, child number 0                                                                                                                                     
    select /*+ use_nl(p) leading(c) gather_plan_statistics */ * from p , c where p.id = c.id and                                                                              
    c.id in (10)                                                                                                                                                              
    Plan hash value: 2553281496                                                                                                                                               
    | Id  | Operation                     | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |                                                                 
    |   0 | SELECT STATEMENT              |      |      0 |        |      0 |00:00:00.01 |       0 |      0 |                                                                 
    |   1 |  TABLE ACCESS BY INDEX ROWID  | P    |      1 |      1 |    100 |00:00:00.01 |     112 |      2 |                                                                 
    |   2 |   NESTED LOOPS                |      |      1 |      1 |    201 |00:00:00.02 |     110 |      2 |                                                                 
    |   3 |    TABLE ACCESS BY INDEX ROWID| C    |      1 |      1 |    100 |00:00:00.01 |       7 |      1 |                                                                 
    |*  4 |     INDEX RANGE SCAN          | C_ID |      1 |      1 |    100 |00:00:00.01 |       3 |      1 |                                                                 
    |*  5 |    INDEX RANGE SCAN           | P_ID |    100 |      1 |    100 |00:00:00.01 |     103 |      1 |                                                                 
    Predicate Information (identified by operation id):                                                                                                                       
       4 - access("C"."ID"=10)                                                                                                                                                
       5 - access("P"."ID"=10)                                                                                                                                                
    24 rows selected.
    SQL> select /*+ use_nl(c) leading(p) gather_plan_statistics */ * from p , c where p.id = c.id and c.id in (10) ;
            ID FILLER                                                                                                       ID                                                
    FILLER                                                                                                                                                                    
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    zrGZSmUFXNyNMOViUYSvPDdfznSlMvaFnQakopPtcBvXQkWmMlWCnrPyeZLfhuLLeYyAEkcwZNSfoASLYpoAnpESqlQWkaEGatXV                                                                      
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    hKtrWPCfAmWWLGMXfwHCusSwVpehEnZdxYPLouIuBlMMiSKlIJWwklZCAXZaCbIxKlhzBVRhhTPdLcheyAdoYyfxwomqWRrMXuMk                                                                      
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    ncSqclZvOGgyXDPaaouGaUqXmJtFNbNyFzUalDknEMvTsBRwGmTxOCIalLvqMnuTFBZJGzNfBqaSVHUtvNDceVZqKQQyqeGKOUdz                                                                      
    100 rows selected.
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST')) ;
    PLAN_TABLE_OUTPUT                                                                                                                                                         
    SQL_ID  7hvf1zvsvfhdp, child number 0                                                                                                                                     
    select /*+ use_nl(c) leading(p) gather_plan_statistics */ * from p , c where p.id =                                                                                       
    c.id and c.id in (10)                                                                                                                                                     
    Plan hash value: 2133717140                                                                                                                                               
    | Id  | Operation                     | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers |                                                                          
    |   0 | SELECT STATEMENT              |      |      0 |        |      0 |00:00:00.01 |       0 |                                                                          
    |   1 |  TABLE ACCESS BY INDEX ROWID  | C    |      1 |      1 |    100 |00:00:00.01 |      11 |                                                                          
    |   2 |   NESTED LOOPS                |      |      1 |      1 |    102 |00:00:00.01 |       7 |                                                                          
    |   3 |    TABLE ACCESS BY INDEX ROWID| P    |      1 |      1 |      1 |00:00:00.01 |       4 |                                                                          
    |*  4 |     INDEX RANGE SCAN          | P_ID |      1 |      1 |      1 |00:00:00.01 |       3 |                                                                          
    |*  5 |    INDEX RANGE SCAN           | C_ID |      1 |      1 |    100 |00:00:00.01 |       3 |                                                                          
    Predicate Information (identified by operation id):                                                                                                                       
       4 - access("P"."ID"=10)                                                                                                                                                
       5 - access("C"."ID"=10)                                                                                                                                                
    24 rows selected.
    SQL> drop table p purge ;
    Table dropped.
    SQL> drop table c purge ;
    Table dropped.
    SQL> spool offEdited by: user503699 on Jan 18, 2012 11:49 PM

  • Jdev 11g: several attributes are not supported by "simple" graph types

    Hi,
    My question is especially for Jdev development team. I want to discuss this issues first in this forum before I open a SR at Oracle Support.
    Several attributes from dvt:graph are not supported in dvt:areagraph, dvt:linegraph or dvt:bargraph.
    - TimeSelectorListener
    - TimeRangeMode
    - TimeAxisType --> supported for dvt:linegraph but not for dvt:areagraph. Why?
    - TimeAxisListener
    - TimeZone
    - ExplicitTimeRangeStart
    - ExplicitTimeRangeEnd
    - ContinuousTimeAxisInterval
    This means if I want (need) to use some of this attributes I need to use dvt:graph (advanced graph).
    But here is the next problem:
    This type of graph can't be selected from component palette or graph create wizard.
    It's still possible to "convert" e.g. a dvt:linegraph to dvt:graph by editing the source code of jspx but in my opinion this should not be the normal way!
    I also didn't get a clear answere if dvt:graph is desupported or will be desupported in the next release(s)
    (see my previous post about advanced graph: Jdev 11g: Advanced graph no longer supported?
    Conclusio:
    ======
    If the attributes I mention above are still supported and needed (also in further releases) than they either need to be supported by the relevant simple graph tags or dvt:graph must be selectable from component palette.
    If dvt:graph is planned to be de-supported in further releases than this should be made public to avoid development of applications with non-supported components.
    regards
    Peter

    Peter,
    you should have followed up on the thread you reference. First of all, Katia gave you the answer of how to get the listener working
    "The recommended way is to create a line graph, and then add a time selector tag (like Peter pointed out).
    However, since in the dvt:lineGraph there is no attribute for the time selector listener, you need to add the listener in the backing bean.
    Here are the code snippets:
    In jspx:
    <dvt:lineGraph id="master"
    value="#{bindings.master1Graph.graphModel}"
    style="Comet"
    imageFormat="FLASH" imageWidth="400"
    binding="#{sampleGraph.richTimeSelectorMasterGraph}"
    animationOnDisplay="AUTO"
    imageHeight="250">
    <dvt:legendArea rendered="false"/>
    <dvt:timeSelector explicitStart="#{sampleGraph.startDate}" explicitEnd="#{sampleGraph.endDate}" fillColor="#33FFFFFF" borderColor="#313675" mode="EXPLICIT" />
    <dvt:seriesSet defaultMarkerType="MT_CURVE_LINE">
    <dvt:series id="0" color="#FDB026"/>
    </dvt:seriesSet>
    </dvt:lineGraph>
    In the backing bean:
    public UIGraph getRichTimeSelectorMasterGraph()
    if (m_richTimeSelectorMasterGraph == null)
    m_richTimeSelectorMasterGraph = new UIGraph();
    m_richTimeSelectorMasterGraph.addTimeSelectorListener(this);
    return m_richTimeSelectorMasterGraph;
    public void setRichTimeSelectorMasterGraph(UIGraph graph)
    m_richTimeSelectorMasterGraph = graph;
    Second, you got Katia's attention already and this is as much developer contact you can get on this forum. Katia ia the product manager for DVT
    Frank

  • Simple  Fact Calculation Help

    Hi Team
    I need help in creating a simple fact calculation. I need to create a fact column that should give the lastest transaction amount , if the type of the transacion is "DEBIT". for example if there 100 transactions are there, and out of that only 25 are DEBIT Transaction, I need the amount of the last (Most recent date's) DEBIT Transaction.
    Please help me, what should be the calculation and the aggrecate setting of that fact column.
    Our version is OBIEE 10.1.3.4.1
    Thanks a lot for the help
    With Regards
    Bas

    The analytics function that yo search is last.
    Check here:
    http://gerardnico.com/wiki/dat/obiee/last_first
    Try to apply the last on only one dimension (ie time dimension) otherwise it can take a lot of time. Check the bad performance section of the article.
    Cheers
    Nico

  • Calculations with date fields

    I'm trying to do a basic calculation with a CRM date form in BC.
    I have a form field 'dateJoined' (though this could easily be the standard DOB field for the sake of this exercies) and I need to use javascript to calculate how many days have passed between today's date and the date in 'dateJoined'.
    The {module_customerfield} outputs a string, not a date object, which would be fine but the format of the string is not compatible with the .date object.
    I started down the path of lengthy substrings > variables, then linked variables > date object but after lines and lines of code, wondered if there was a simpler way that I was overlooking??

    I'm trying to do a basic calculation with a CRM date form in BC.
    I have a form field 'dateJoined' (though this could easily be the standard DOB field for the sake of this exercies) and I need to use javascript to calculate how many days have passed between today's date and the date in 'dateJoined'.
    The {module_customerfield} outputs a string, not a date object, which would be fine but the format of the string is not compatible with the .date object.
    I started down the path of lengthy substrings > variables, then linked variables > date object but after lines and lines of code, wondered if there was a simpler way that I was overlooking??

  • Calculations with Cumulated CKFs

    Hey,
    I need to make additional calculations on the values of a CKF that is marked as cumulated.
    We know that the calculation made on this column are executed against the non-cumulated value, and we basically need to execute them on the cumulated value.
    Can you please provide some insight on the ways to deal with this limitation?(BTW - we tried to check the "cumulated" checkbox for the calculated column and that doesn't help of course.
    Thanks,
    Gili
    Message was edited by: Gilad Weinbach

    Hi,
    and thx for the quick answer. But unfortunately the Server Complex Aggregate aggregation doesn't solve my problem. I also think I didn't express my self clear enough.
    My problem is, that I have the same tuple multiple times in my database table. When I sum this data up - I get wrong results. To avoid this I used the SUM DISTINCT aggregation. This worked very fine. But now I'm facing an other problem. I have to perform a simple subtraction.
    I have a fixed non measure value. I have to subtract the Sum Distinct measure from this fix value for a specified time periode.
    it looks like this:
    Pivot table
    Name --- Days available(non measure) --- Work date --- Days worked (SUM) measure --- Days worked SUM(Distinct) measure
    Mr.A --- 40 --- 1.5 --- 6 --- 3
    Mr.A --- 40 --- 1.5 --- 6 --- 3
    Mr.A --- 40 --- 2.5 --- 6 --- 3
    Mr.A --- 40 --- 3.5 --- 6 --- 3
    Mr.A --- 40 --- 3.5 --- 6 --- 3
    Mr.A --- 40 --- 3.5 --- 6 --- 3
    SUM ---- 40 --- .... ---- 6 --- 3 -> Days left: 34 (wrong result - should be 37)
    I get the right result - but when I now try to calculate "Days available - Days worked SUM(Distinct)" I get the same results like I would do the calculation with
    "Days available - Days worked SUM".
    And is there a way to hide the multiple values in Days worked?
    thx

  • Calculations with Sum Distinct Aggregations

    Hi,
    I got a problem. I use in one of my analysis a Pivot Table. One of my measures which I sum up has multiple entries in my tables. So I decided to use a Sum Distinct aggregation. The Sum Distinct aggregation works perfect. But when I want to do basic calculations with the measure I get wrong results. It seems that in the calculation the aggregation is just a SUM and not a Sum Distinct. In the calculation I subtract the measure from a constant. But I only get wrong result with the redundant entries.
    Pivot table:
    Name --- Days available --- Days worked (measure)--- Days left (= Days available minus Days worked)
    Mr. A --- 60 --- 5 ---- 55
    Mr. A --- 60 --- 10 --- 50
    Mr. A --- 60 --- 35 --- 25
    ---------- Sum ---- 50 --- -45 (wrong result)
    Is there a solution to this problem?
    thx
    Edited by: Backlit on 31.07.2011 11:29

    Hi,
    and thx for the quick answer. But unfortunately the Server Complex Aggregate aggregation doesn't solve my problem. I also think I didn't express my self clear enough.
    My problem is, that I have the same tuple multiple times in my database table. When I sum this data up - I get wrong results. To avoid this I used the SUM DISTINCT aggregation. This worked very fine. But now I'm facing an other problem. I have to perform a simple subtraction.
    I have a fixed non measure value. I have to subtract the Sum Distinct measure from this fix value for a specified time periode.
    it looks like this:
    Pivot table
    Name --- Days available(non measure) --- Work date --- Days worked (SUM) measure --- Days worked SUM(Distinct) measure
    Mr.A --- 40 --- 1.5 --- 6 --- 3
    Mr.A --- 40 --- 1.5 --- 6 --- 3
    Mr.A --- 40 --- 2.5 --- 6 --- 3
    Mr.A --- 40 --- 3.5 --- 6 --- 3
    Mr.A --- 40 --- 3.5 --- 6 --- 3
    Mr.A --- 40 --- 3.5 --- 6 --- 3
    SUM ---- 40 --- .... ---- 6 --- 3 -> Days left: 34 (wrong result - should be 37)
    I get the right result - but when I now try to calculate "Days available - Days worked SUM(Distinct)" I get the same results like I would do the calculation with
    "Days available - Days worked SUM".
    And is there a way to hide the multiple values in Days worked?
    thx

  • Prime Graphing Calculator Identifica​tion of Older Prime Hardware Version A

    Hello,
    I have been trying to update the firmware version to the latest version (2014 07 02 (6031)) on my Prime Graphing Calculator without luck, the release_info.txt file indicates that (for firmware version 2014 03 31 (6030)):
    There is limited backward compatibility between this and earlier releases.
    Older Prime hardware (Revision A) does support this release, however the wireless, unit-to-unit, and data streamer functionality is not supported on earlier models. In the Help->About HP Prime screen the hardware revision will be displayed along with software version information.
    How can I tell if my calculator hardware number is the Revision A hardware?
    Is the CAS version the hardware number?
    Thank you very much,
    H.
    This question was solved.
    View Solution.

    Hi,
    All HP Primes are upgradeable to version 6030 (note that 6031 is for the PC emulator only). It is just that Hardware A has a problem with some communications.
    Firmware versions prior to 6030 (i.e. 5447 and older) do not show the hardware version in the 'about' screen.
    When you upgrade to 6030 the hardware version will be displayed in the 'about' screen.
    You can also determine the hardware version from the model number (found on the back of the box it came in, near the bar code):
    NW280AA is Revision A hardware
    G8X92AA is Revision C hardware
    By the way, the following process is recommended for upgrading the Prime:
    Install the Connectivity Kit from the CD.
    Once the connectivity kit is installed, update the calculator.
    The following method is recommended:
    Connect your HP Prime calculator via the supplied USB cable (directly connected, do not use a USB hub)
    Start the HP Connectivity Kit 
    Click the Calculator tab 
    Right-click the name of the HP Prime you wish to update (it would be the one you connected before starting this procedure) 
    Make a note of the version number and then click the OK button 
    Click on the Help Menu and select Check for update 
    Check for update pop-up box, check version number that it is newer than the one you wish to update. 
    Then click download button 
    That's it, you'll see on the screen of your calculator the update being loaded and installed. Don't click too fast to get out of the HP Connectivity Kit, wait a minute or so after completion. 
    Also, there is a step in the Connectivity Kit where it is advised to back-up the version you had before you run the procedure, just in case. That way you have a way to re-cover.
    Regards.
    Note: I do not work for HP, I just like playing with calculators :-)

  • Help with parallel arrays of different data types

    Hello all, I am having an issue with parallel arrays. My program requires me to read information from a text file into 4 parallel arrays (2 String and 2 double). My text file needs to look something like this:
    John Johnson
    0000004738294961
    502.67
    1000.000
    Jane Smith
    0000005296847913
    284.51
    1000.000
    ...and so on
    Where the first thing is the name (obviously), an account number, the balance in the account, and the credit limit. I just cant figure out how to read everything into the arrays. We havent learned anything too heavy, and this seems a little too advanced for my class, but I guess we will manage. Any help will be appreciated. Thanks guys.
    Casey

    Man this is a dumb homework assignment. The requirements scream out for a class along the lines of
    public class Account{
      private String name, number;
      private double balance,creditlimit;
       // more code here
    }and then to use a List of Account objects.
    Anyway what's your actual problem. There's nothing very hard about it. A loop. So....
    You should consider posting (formatted) code showing what you have done and where exactly you are stuck.

  • Preference calculation with batch management

    Hi experts,
    I am trying to find any documentation or manuals about how to set-up and use preference calculation in SAP-SD-FT or GTS based on batch management.
    Does anyone of you know how to do it and use such kind of "standard"-SAP-solution or is customer-specific programming essential.
    Any reply would be much appreciated.
    Best regards,
    Corinne

    Hi Corinne,
    Did you get anything for your requirement specific to Preference calculation with batch management. I am also looking for the same. let me know if you found something useful or if you created an enhancement to resolve this issue.
    Regards,
    Sumit

  • Performance Problems with intrinsic array multiplikation in Fortran with Su

    Hello,
    I found a serious performance problem in my application with intrinsic array multiplikation. Therefore I wrote a small test program to check if this a general problem or only exists in my code.
    The test program (as seen below) was compiled with Sunstudio12 und Solaris 5.10 on an 64 bit Amd Opteron Machine. First with high optimization (f95 -fast -g), and the second time with out optimization (f95 -O0 -g). In both cases the intrinsic array mupltiplication had a lot of tlb and L2 cache misses (I made some test with the performance analyzer) which caused a huge increase in computation time compared to the explicit loop. In the ideal case the compiler should create the nested loops from the intrinsic statement and both functions should use exactly the same computing time.
    I also tried compiling with Studio11, the problem also occurs there. Maybe its a compiler bug but I'm not sure.
    Greetings
    Michael Kroeger
    program test
    !Test zur Ausfuehrung einer einfachen array Multiplikation
    implicit none
    real,dimension(:,:,:),pointer::check1,check2
    integer i,j,k,ni,nj,nk,status
    ni=1000
    nj=1000
    nk=100
    allocate(check1(0:ni,0:nj,0:nk),STAT=status)
    write(*,*)status
    allocate(check2(0:ni,0:nj,0:nk),STAT=status)
    write(*,*)status
    check1(i,j,k)=25
    check2(i,j,k)=25
    call intrinsic_f(check1)
    call withloop(check2,i,j,k)
    deallocate(check1,check2)
    contains
    subroutine intrinsic_f(check1)
    real, dimension(:,:,:),pointer::check1
    check1=check1*5
    end subroutine intrinsic_f
    subroutine withloop(check2,ni,nj,nk)
    real, dimension(:,:,:),pointer::check2
    integer i,j,k,nk,nj,ni
    do k=0,nk
    do j=0,nj
    do i=0,ni
    check2(i,j,k)=check2(i,j,k)*5
    enddo
    enddo
    enddo
    end subroutine withloop
    end program

    I will try the large pages, but what me puzzles is, that the intrinsic function has cache misses, but the loop function has not. All documentation says, that the compiler would expand the intrinsic function into 3 nested loops, so that both functions should be essential the same (and the compiler says it has created 3 loops from the intrinsic). Since they are not the same, this is a severe problem.
    I have a fairly large code for high performance simulations, and this intrinsic functions are a significant bottle neck. If it is not a compiler bug, I would have to rewrite all intrinsic functions into loops.

Maybe you are looking for