`ttest` <-
function(x, y, var.equal=FALSE)
{    
    x = x[!is.na(x)]
    y = y[!is.na(y)]

    lx = length(x)
    ly = length(y)

    if(lx <=2 || ly <=2){
        stop("not enough observations...\n")
    }
    
    tstat = pv = 0

    if(var.equal){
        Z = .C("tctest", as.double(x), as.integer(lx), as.double(y), 
            as.integer(ly),  tstat=as.double(tstat), pv=as.double(pv), 
            PACKAGE="permuteP")
    }else{
        Z = .C("tutest", as.double(x), as.integer(lx), as.double(y), 
            as.integer(ly),  tstat=as.double(tstat), pv=as.double(pv), 
            PACKAGE="permuteP")
    }
    
    list(tstat=Z[["tstat"]], pval=Z[["pv"]])
}
