title: Java.Lang.Double[] to Double[] issue for Polynomial from CSV
body: <p>First of all thanks for your help in advance.</p>
  
  <p>I'm writing an investment algorithm and am currently pre-processing CSV historical data. The end goal for this part of the process is to create a symmetrical co-variance matrix of 2k x 2k / 2 (2 million) entries.</p>
  
  <p>The Java class I'm writing takes a folder of CSVs each with 8 bits of information, key ones being Date, Time &amp; Opening stock price. Date &amp; time have been combined into one 'seconds from delta' time measure and opening stock prices remain unchanged. The output CSV contains the above two pieces of information also with a filename index for later referencing.</p>
  
  <p>In order to create the co-variance matrix each stock on the NYSE must have a price value for every time, if values are missing the matrix cannot be properly completed. Due to discrepancies between time entries in the historical training CSV, I have to use a polynomial function to estimate missed values, which then can be fed into the next process in the chain.</p>
  
  <p>My problem sounds fairly simple and should be easy to overcome (I'm probably being a massive idiot). The polynomial package I'm using takes in two arrays of doubles (Double[] x, Double[] y). X pertaining to an array of the 'seconds past delta' time values of a particular stock and Y the corresponding price. When I try to feed these in I'm getting a type error as what I'm actually trying to input are 'java.lang.Double' objects. Can anyone help me with converting an array of the latter to an array of the former?</p>
  
  <p>I realise there is a load of ridiculousness after the main print statement, these are just me tinkering trying to miraculously change the type.</p>
  
  <p>Again thanks for your time, I look forward to your replies!</p>
  
  <p>Please find the relevant method below:</p>
  
  <pre><code>public void main(String filePath) throws IOException {
  
      String index = filePath;
      index = index.replace("/Users/louislimon/Desktop/Invest Algorithm/Data/Samples US Stock Data/data-1/5 min/us/nyse stocks/1/", "");
      index = index.replace(".us.txt", "");
  
      File fout = new File("/Users/louislimon/Desktop/Invest Algorithm/Data.csv");
      FileOutputStream fos = new FileOutputStream(fout);
      BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));
  
  
      Reader in = new FileReader(filePath);
  
      Iterable&lt;CSVRecord&gt; records;
  
      try {
  
          records = CSVFormat.EXCEL.withSkipHeaderRecord(true).parse(in);
  
      } catch ( IOException ex ) {
          System.out.println ( "[ERROR] " + ex );
          return;
      }
  
      ZoneId zoneId = ZoneId.of("America/New_York");
  
      boolean tmp = true;
  
      Instant firstInstant = null; // Track the baseline against which we calculate the increasing time
  
  
      ArrayList&lt;Double&gt; timeVals = new ArrayList&lt;Double&gt;();
      ArrayList&lt;Double&gt; priceVals = new ArrayList&lt;Double&gt;();
  
      for ( CSVRecord record : records ) {
  
          if(tmp){
              tmp = false;
          }
          else {
              //System.out.println(record.toString());
  
              String dateInput = record.get(0);
              String timeInput = record.get(1);
              Double price = Double.parseDouble(record.get(2));
  
              LocalDate date = LocalDate.parse(dateInput);
              LocalTime time = LocalTime.parse(timeInput);
              //Double price = Double.parseDouble(priceInput);
  
              LocalDateTime ldt = LocalDateTime.of(date, time);
  
              ZonedDateTime zdt = ldt.atZone(zoneId);
  
              Instant instant = zdt.toInstant();  // Use Instant (moment on the timeline in UTC) for data storage, exchange, serialization, database, etc.
              if (null == firstInstant) {
                  firstInstant = instant;  // Capture the first instant.
              }
  
              Duration duration = Duration.between(firstInstant, instant);
              Long deltaInSeconds = duration.getSeconds();
  
              double doubleDeltaInSeconds = deltaInSeconds.doubleValue();
  
              timeVals.add(doubleDeltaInSeconds);
              priceVals.add(price);
  
              //System.out.println("deltaInSeconds: " + deltaInSeconds + " | price: " + price + " | index: " + index);
          }
  
  
          Double [] timeValsArray = timeVals.toArray(new Double[timeVals.size()]);
          Double [] priceValsArray = timeVals.toArray(new Double[priceVals.size()]);
  
  
          Double[] timeFeed = new Double[timeVals.size()];
          Double[] priceFeed = new Double[priceVals.size()];
  
          for(int x = 0;x&lt;timeVals.size(); x++) {
              timeFeed[x] = new Double (timeValsArray[x].doubleValue());
              priceFeed[x] = new Double (priceValsArray[x]);
          }
  
         PolynomialFunctionLagrangeForm pflf =  new PolynomialFunctionLagrangeForm(timeFeed,priceFeed);
      }
  </code></pre>