Operations on Lists of Numbers

I've come across a problem in my code that could have a few different solutions.
First, the problem. This is the code:
     public static List<List<?>> linear_solve(List<List<Double>> m, List<Double> v) throws Exception {
          if(m.size() != v.size()){
               throw new Exception("Incompatible system.");
          List<List<Double>> solution = new ArrayList<List<Double>>(m);
          List<List<?>> result = new ArrayList<List<?>>();
          //Add the values from v onto n
          for(int row = 0; row < solution.size(); row++)
               solution.get(row).add(v.get(row));An error is generated on the last line, when v is of type List<Integer>. This is the error:
java.lang.ClassCastException: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.DoubleWhat confuses me the most here, is why this error is showing up so late. I would assume that the error would be when the program attempts to pass a List<Integer> into a List<Double>.
I have several different functions that behave in the same way, so I'd like to find the most elegant solution. I've thought of simply accepting List<Number>, but I need to be able to use the * operator, which is defined for both Integer and Double, but is not defined for Number. Is it possible, at all, to do this?
Another solution would be to simply cast it, but I can't think of how to do this.
Any help is greatly appreciated.

By the way, the forum software likes to add '>' characters to our posts, as you may have noticed. You can avoid that problem by always using the &lt; escape for the '<' character, or making sure it isn't followed immediately by a letter:   List<List<Double>> solution = new ArrayList< List< Double>>(m); The problem only occurs if the software sees another '<' before the next '>'; it seems to think it's closing our HTML tags for us.

Similar Messages

  • 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

  • How do I add a list of numbers stored in an array

    How do I add a list of numbers stored in an array? The code I
    have is showing ‘NaN’ when I try to add the second item
    in each element of the array:
    var aItemPrices:Array = new Array(["item1_mc", 10], ["item
    2_mc", 20], ["item 3_mc", 30]);
    var totalPrice:Number;
    for (i=0; i<aItemPrices.length; i++) {
    //the following line traces 'NaN'
    totalPrice += aItemPrices
    [1];
    trace("totalPrice: "+ totalPrice);

    i modified your code in 2 places, check it
    var aItemPrices:Array = new Array(["item1_mc", 10], ["item
    2_mc", 20], ["item 3_mc", 30]);
    var totalPrice:Number=0; //Mani changes
    for (i=0; i<aItemPrices.length; i++) {
    //the following line traces 'NaN'
    totalPrice += aItemPrices
    [1];//Mani changes
    trace("totalPrice: "+ totalPrice);

  • How can I sum numbers in a pdf? And, sum a partial list of numbers?

    How can I sum a list (or partial list) of numbers in a pdf?

    Thanks for your answer.  I have Adobe Acrobat 7.0 Professional.  If you
    can help me further by listing the necessary steps that would be great.
    Thanks.
    Barry Baker

  • Operating Unit List Of Values is Null When Entering Transaction Types

    Hi,
    Operating Unit List Of Values is null when entering Transaction Types in Receivables Manager responsibility. I also re-checked MO: Security Profile and MO:Operating Unit Profile options that were set correctly. Please let me know how to troubleshoot the problem and fix accordingly.
    Thanks for the help.
    Regards,
    Sri

    There are some pointers in the below note
    Troubleshooting Transaction Types In Oracle Receivables [ID 1090878.1]
    Mahendra

  • Property loader in .csv Format : Error with list of Numbers

    Hi,
    I need to change property files from the .xls format to the .csv format so that I won't need to install Ms Office on the Test Station PC.
    Everything works is .csv format except for variales containing lists of numbers.  Here is an example.
    This variable contains the channel list to send to a Digital Multimeter.  A string containing all channel numbers seperated by comas (The DMM model is Agilent  34070A). 
    I create a variable named ChannelList of type string containing : "101,102,103,104,105"
    When exporting to property file (Using Tools-Import/Export properties), TestStand will write the following line is .csv format :
    ChannelList,"101,102,103,104,105"
    When trying to import this property value with a property loader I get the following error :
    Runtime Error Occured
    Error evaluating expression:Runstate.Sequence.locals.ChannelList = (""101")
    Unexpected Token: 101
    What puzzles me is that teststand is not even capable of reading its own exported property within a newly created file.
    Any ideas?
    TestStand 2013
    Thanks in advance
    Nien

    Nien,
    This is a known issue and we are looking into this issue in future version of TestStand.
    There are couple of approaches for fixing the problem:
    1. Use a different character for comma in the property loader file. After importing the data, replace the character with comma using TestStand expression in the sequence file.
    2. Use Tab Delimited Text format instead of CSV format.
    3. We can see that, property loader is using expression to update the value of the property (The exact expression is specified in the error message you have posted). In a text editor, update the csv file to have the value as
    ChannelList,101""+Chr(44)+""102""+Chr(44)+""103""+Chr(44)+""104""+Chr(44)+""105
    This will create the expression such that, the value of ChannelList property will become 101,102,103,104,105
    Note: This is just a workaround and you should use this approach with caution.
    Thanks,
    Shashidhar

  • Listing out numbers in rows

    Hi people, i would like to list our numbers 1 to 100, 10 numbers per row. If a number has a 7 in it, it will show 2 asterisks. How could i go about doing it??? Sorry as i'm new to Java. I'd tried but only manged to get all the numbers appearing in 1 column. Thanks.
    public class SevenUp
         static boolean SevenUp(int num)
              if(num==100)
              return false;
              else
                   if(num>9)
                        if (num/10==7)
                        return true;
                        else if(num%10==7)
                        return true;
                        else
                        return false;
                   else
                        if(num==7)
                        return true;
                        else
                        return false;
        public static void main(String[]args)
              int num=1;
              for(int row=0; row<=10; row++)
                   for(int i=1; i<=10; i++)
                        num=i+(row*9);
                         if(SevenUp(num)==true)
                              System.out.println("**\t");
                         else
                              System.out.println(num+"\t");
    }

    Maybe your game isn't what I think it is, but we always played this as "if the number has a 7, or is divisible by 7, then say, 'Buzz'" [where Buzz would be the equivalent of your "**".  You can always modified your SevenUp to add more rules later.
    By the way, using a method named SevenUp in a class named SevenUp is a terrible idea.  Too confusing!  :)
    Besides, the convention is that methods should have names that start with a lowercase letter (e.g., "sevenUp").                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Applescript: how to 2 lists of numbers

    I want to update a variable (list of numbers for coordinates) by adding a second list.
    property winPosVar : {50, 100}
    property winOffsetVar : {50, 50}
    set winPosVar to winPosVar + winOffsetVar
    This gives me an error, but if it worked the way I wanted, it would give me winPosVar = {100,150}.
    Is it possible to add 2 lists without breaking out individiual variables for each item in the list?

    Use code such as:
    set list1 to {50, 100}
    set list2 to {50, 50}
    set list3 to {}
    repeat with this_num from 1 to (count list1)
    set list3 to list3 & ((item this_num of list1) + (item this_num of list2))
    end repeat
    (87577)

  • Cannot perform scripting operations on lists

    Hi,
    I'm having trouble performing scripting operations on lists, the only variables I can retrieve from lists are the values @HasLeadSelection, @LeadSelectedIndex and @RowCount. I cannot perform any methods on lists, I have gone through the Complete Help document and have also tried to use Resolve to attempt to access list rows but that doesn't seem to working either. Any help would be greatly appreciated!
    Thanks
    Alexander Ludwig

    Hi Alessandro & Alexander,
    I just tried it and yes we can change the colour trough scripting as well.
    Something like below in the Calculation Rule of the property Background Colour would do the job.
    result = 'STANDARD'  // This is a fallback value in case the if condition below is not satisfied.
    if( $currentrow.xxx == 'xx' )  // Here xxx should be the element within the table
    result = 'BADVALUE_DARK'   // This is one of the value from above screenshot.
    end
    Check this other thread for more details:http://scn.sap.com/thread/3528872
    And yeah the code completion is having serious issues. It shows the attributes which do not belong under is sometimes.
    Binding to another attribute and setting it trough ABSL might decrease the performance as there would be a roundtrip required in this case to change the value if this field is not shown on UI and is only used to decide the colour.
    Regards
    Vinod

  • How to find max value from a list of numbers stored in a varray?

    hi,
    Can any body help me to get the max value from a list of numbers stored in a varray?
    thanks in advance....
    regards
    LaxmiNarsimha

    Yes. Could you post what you have tried before we start helping you in this?

  • Query to list seqencial numbers

    Hi,
    I would like to know how to list sequential numbers upto 10 and the last row as the sum of all numbers.
    like
    1
    2
    3
    10
    55
    thanks

    With 10g.
    REagrds Salim.
    SELECT    col1
      FROM   dual
       MODEL
        DIMENSION BY (1 rn)
        MEASURES     (1 col1)
        RULES
        (col1[FOR rn FROM  1 TO 10 INCREMENT 1] =cv(rn),
          col1[11]=sum(col1)[any] )
    SQL> SELECT    col1
      2    FROM   dual
      3     MODEL
      4      DIMENSION BY (1 rn)
      5      MEASURES     (1 col1)
      6      RULES
      7      (col1[FOR rn FROM  1 TO 10 INCREMENT 1] =cv(rn),
      8        col1[11]=sum(col1)[any] )
      9  /
          COL1
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
            55
    11 rows selected.
    SQL>

  • List of numbers that have called my house

    We need a list of numbers (long distance) that have called our house sine Oct of 07. Really we just need a report of a certain number and what days that number called the house.  Is there anyway to do this without calling customer service??

    NO.

  • Modem dialing a list of numbers

    Hi, i'm trying to have my mac do the following:
    I have a list of phone numbers or a text file with a list of numbers that i need to verify as working. I need to hear that a machine answers.
    I want to use a modem to dial the numbers.
    Any advice ? I have some unix scripting experiance.
    ThHank you in advance

        Hi, mjdean1982-
    You can see your messaging usage details by logging into vzw.com/myverizon and clicking 'View Bill'. This will allow you to view voice/messaging/data details by line.
    Thanks,
    AdamE_VZW
    Follow us on Twitter @VZWSupport

  • How to find number of occurance of each number in big list of numbers?

    I got big list of numbers.
    examples......4,6,30,39,27,6,25,5,6,4,
    I want to find,
    4 occur 2 times
    6 occur 3 times
    etc...
    How to do this?.
    Do we have a custom tag doing this?.
    Please let me know

    dan bracuk was my insipiration for this suggestion...
    <cfset arr = ListToArray("4,6,30,39,27,6,25,5,6,4")>
    <cfset qry = QueryNew("tmp")>
    <cfset QueryAddColumn(qry, "num", arr)>
    <cfquery name="qTotal" dbtype="query">
    SELECT num, count(num) occur
    FROM qry
    GROUP BY num
    </cfquery>
    <cfdump var="#qTotal#">

  • How do I generate random numbers from a list of numbers without repeating any number

    I am trying to generate a list of random numbers without any repeating numbers.  For example say the list is from 1 to 15, how do I randomly generate a list of numbers using each number only once?

    pb,
    You can build a randomizer by making a 2-column table with 15 rows. In Column A, Fill with the numbers 1 to 15. In column B Fill with RAND(). Then sort on Column B. There will now be a randomized list of the numbers from 1 to 15 in Column A. You can copy this random list and use it in your application.
    Jerry

Maybe you are looking for

  • BI_SDK_XMLA J2ee project - Can't get instance from Connection Factory

    Hi: The code: initctx = new InitialContext(); connectionFactory=(IConnectionFactory) initctx.lookup("java:comp/env/" + "SDK_XMLA"); At debug time I watch: initctx.lookup("java:comp/env/" + "SDK_XMLA")"= XmlaConnectionFactory (id=333) m_connectionMana

  • N97 - Maps/Navigation Question (probably a rather ...

    I have managed to update my actual maps. So that's good. My compass seems to work, so that is also good. Before the Maps update I managed to save my home address and set it as a Favourite. Since the update of Maps (the app) and the actual maps themse

  • Performance tuning on BKPF and BSEG for my code.

    Please provide alternative code for the following code so that processing is fast. my select queries are as follows. It take a lot of time and system gets loaded when it is scheduled. select BUKRS            BELNR            GJAHR            BLART   

  • Another oci8 question

    Hi there, Sorry to ask what seems to be a common question, but I've been trawling through threads and walkthroughs for a couple of days now and don't seem to be able to crack the problem I'm having. Running Win XP with Oracle 10g installed. I'm using

  • HT4113 i can't access my ipad what can i do?

    i can't access my ipad what can i do?