Ignore:
Timestamp:
11/29/11 18:26:55 (5 years ago)
Author:
gkronber
Message:

#1081: reverse merged r6802, r6807-6808, r6811, r6974, r7058 to prepare for the 3.3.6 release

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/AlglibUtil.cs

    r6802 r7097  
    2727  public static class AlglibUtil {
    2828    public static double[,] PrepareInputMatrix(Dataset dataset, IEnumerable<string> variables, IEnumerable<int> rows) {
    29       return PrepareInputMatrix(dataset, variables, rows, new int[] { 0 });
    30     }
     29      List<string> variablesList = variables.ToList();
     30      List<int> rowsList = rows.ToList();
    3131
    32     public static double[,] PrepareInputMatrix(Dataset dataset, IEnumerable<string> variables, IEnumerable<int> rows, IEnumerable<int> lags) {
    33       int maxLag = lags.Max();
    34 
    35       // drop last variable (target variable)
    36       List<string> inputVariablesList = variables
    37         .Reverse()
    38         .Skip(1)
    39         .Reverse()
    40         .ToList();
    41       string targetVariable = variables.Last();
    42       List<int> rowsList = rows.ToList();
    43       int nRows = rowsList.Count - maxLag;
    44       double[,] matrix = new double[nRows, inputVariablesList.Count * lags.Count() + 1];
     32      double[,] matrix = new double[rowsList.Count, variablesList.Count];
    4533
    4634      int col = 0;
    47       int row = 0;
    48       // input variables
    49       foreach (int lag in lags) {
    50         foreach (string column in inputVariablesList) {
    51           var values = dataset.GetDoubleValues(column, rows.Select(x => x - lag).Take(nRows));
    52           row = 0;
    53           foreach (var value in values) {
    54             if (row >= 0) {
    55               matrix[row, col] = value;
    56             }
    57             row++;
    58           }
    59           col++;
     35      foreach (string column in variables) {
     36        var values = dataset.GetDoubleValues(column, rows);
     37        int row = 0;
     38        foreach (var value in values) {
     39          matrix[row, col] = value;
     40          row++;
    6041        }
     42        col++;
    6143      }
    62       // target variable
    63       row = 0;
    64       foreach (var value in dataset.GetDoubleValues(targetVariable, rows).Take(nRows)) {
    65         matrix[row, col] = value;
    66         row++;
    67       }
     44
    6845      return matrix;
    6946    }
Note: See TracChangeset for help on using the changeset viewer.