Skip to content
Snippets Groups Projects
Commit c0e9de76 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

add specialization to Sd

parent 03c34360
Branches
No related tags found
No related merge requests found
/*
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -24,6 +24,7 @@ package com.oracle.truffle.r.nodes.builtin.stats;
import static com.oracle.truffle.r.runtime.RBuiltinKind.*;
import com.oracle.truffle.api.*;
import com.oracle.truffle.api.dsl.*;
import com.oracle.truffle.api.frame.*;
import com.oracle.truffle.r.nodes.*;
......@@ -54,6 +55,7 @@ public abstract class Sd extends RBuiltinNode {
@SuppressWarnings("unused")
protected double sd(VirtualFrame frame, RDoubleVector x, byte narm) {
controlVisibility();
double xmean = (double) mean.executeDouble(frame, x);
double distSum = 0.0;
for (int i = 0; i < x.getLength(); ++i) {
......@@ -61,4 +63,13 @@ public abstract class Sd extends RBuiltinNode {
}
return sqrt.sqrt(div.op(distSum, x.getLength() - 1));
}
@Specialization
protected double sd(VirtualFrame frame, RDoubleVector x, RArgsValuesAndNames rargs) {
if (rargs.getValues().length > 0) {
CompilerDirectives.transferToInterpreter();
throw RInternalError.unimplemented();
}
return sd(frame, x, RRuntime.LOGICAL_FALSE);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment