class NormalizeRows extends SingleParentVariable<Matrix> {

    @Override
    public Matrix apply(ComputationContext ctx) {
        double[] parentData = ctx.data(parent()).data();
        int rows = this.rows;
        int cols = this.cols;
        double[] result = new double[rows * cols];
        for (int row = 0; row < rows; row++) {
            double sum = 0;
            for (int col = 0; col < cols; col++) {
                int elementIndex = row * cols + col;
                sum += Math.pow(parentData[elementIndex], 2);
            }
            double l2 = Math.sqrt(sum);
            for (int col = 0; col < cols; col++) {
                int elementIndex = row * cols + col;
                result[elementIndex] = parentData[elementIndex] / l2;
            }
        }
        return new Matrix(result, this.rows, this.cols);
    }

    public  NormalizeRows(Variable<Matrix> matrix);

}