Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**
     * downsamples the data by the given factor
     *
     * @param factor downsample factor
     * @param data the data
     */
    public static double[] downsample(int factor, double[] data) {
        double[] downsampledData = new double[(int) Math.ceil(data.length / factor)];
        int counter = 0;
        for (int i = 0; i < data.length; i += factor) {
            downsampledData[counter] = data[i];
            counter++;
        }
        return downsampledData;
    }
}