[Yuima-commits] r327 - in pkg/yuima: . src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Sep 8 12:18:55 CEST 2014


Author: kyuta
Date: 2014-09-08 12:18:54 +0200 (Mon, 08 Sep 2014)
New Revision: 327

Modified:
   pkg/yuima/DESCRIPTION
   pkg/yuima/NEWS
   pkg/yuima/src/cce_functions.c
Log:
fixed a bug in cce_functions.c

Modified: pkg/yuima/DESCRIPTION
===================================================================
--- pkg/yuima/DESCRIPTION	2014-09-06 10:05:56 UTC (rev 326)
+++ pkg/yuima/DESCRIPTION	2014-09-08 10:18:54 UTC (rev 327)
@@ -1,8 +1,8 @@
 Package: yuima
 Type: Package
 Title: The YUIMA Project package for SDEs
-Version: 1.0.29
-Date: 2014-09-06
+Version: 1.0.30
+Date: 2014-09-08
 Depends: methods, zoo, stats4, utils, expm, cubature, mvtnorm
 Author: YUIMA Project Team
 Maintainer: Stefano M. Iacus <stefano.iacus at unimi.it>

Modified: pkg/yuima/NEWS
===================================================================
--- pkg/yuima/NEWS	2014-09-06 10:05:56 UTC (rev 326)
+++ pkg/yuima/NEWS	2014-09-08 10:18:54 UTC (rev 327)
@@ -20,4 +20,5 @@
 2014/04/28: modified qmle, added carma, modified lasso
 2014/05/04: modified show method, setYuima sets the sampling from the data if sampling is missing
 2014/07/07: modified llag.R, llag.Rd, cce_functions.c; estimated cross-correlation functions are converted to values in [-1,1]
-2014/07/31: fixed setSampling and print methods
\ No newline at end of file
+2014/07/31: fixed setSampling and print methods
+2014/09/08: fixed a bug in cce_functions.c
\ No newline at end of file

Modified: pkg/yuima/src/cce_functions.c
===================================================================
--- pkg/yuima/src/cce_functions.c	2014-09-06 10:05:56 UTC (rev 326)
+++ pkg/yuima/src/cce_functions.c	2014-09-08 10:18:54 UTC (rev 327)
@@ -1,15 +1,14 @@
 #include <Rinternals.h>
 #include <math.h>
 
-void ctsubsampling(double *znum, double *ztime, int *frequency, int *nsparse,
-                   int *n, double *grid, double *result)
+void ctsubsampling(double *znum, double *ztime, int *frequency, int *nsparse, int *n, double *grid, double *result)
 {
   int t, i, k;
-  
+   
   for(t = 0; t < *frequency; t++){
-    k = 1;
     for(i = 0; i < *nsparse; i++){
-      while((ztime[k]<=grid[i])&&(k < *n)){
+        k = 1;
+      while((ztime[k]<=grid[i])&&(k<*n)){
         k++;
       }
       result[(*nsparse)*t+i] += znum[k-1];
@@ -21,16 +20,18 @@
 
 
 void refreshsampling(int *Dim, int* I, double *Times, double *rtimes,
-                     int *Lengths, double *MinTime, int *MinL,
+                     int *Lengths, int *D, double *MinTime, int *MinL,
                      int *Samplings)
 {
   int d, i, J;
   double Tmp;
   
   for(d = 0; d < *Dim; d++) {
-    while(Times[Lengths[d] * d + (I[d]+1)] <= rtimes[0]){
+    /*while(Times[Lengths[d] * d + (I[d]+1)] <= rtimes[0]){*/
+    while(Times[D[d] + (I[d]+1)] <= rtimes[0]){
       I[d]++;
-      if((I[d]+1) >= Lengths[d + 1]){
+      /*if((I[d]+1) >= Lengths[d + 1]){*/
+      if((I[d]+1) >= Lengths[d]){
         break;
       }
     }
@@ -46,9 +47,11 @@
     for(d = 0; d < *Dim; d++) {
       Tmp = rtimes[i];
       J = I[d];
-      while((J < (Lengths[d + 1]-1)) && (Tmp <= rtimes[i])) {
+      /*while((J < (Lengths[d + 1]-1)) && (Tmp <= rtimes[i])) {*/
+      while((J < (Lengths[d]-1)) && (Tmp <= rtimes[i])) {
         J++;
-        Tmp = Times[Lengths[d] * d + J];
+        /*Tmp = Times[Lengths[d] * d + J];*/
+        Tmp = Times[D[d] + J];
       }
       if(Tmp > rtimes[i + 1])
         rtimes[i + 1] = Tmp;
@@ -57,9 +60,11 @@
     i++;
       
     for(d = 0; d < *Dim; d++) {
-      while(Times[Lengths[d] * d + (I[d]+1)] <= rtimes[i]){
+      /*while(Times[Lengths[d] * d + (I[d]+1)] <= rtimes[i]){*/
+      while(Times[D[d] + (I[d]+1)] <= rtimes[i]){
         I[d]++;
-        if((I[d]+1) >= Lengths[d + 1]){
+        /*if((I[d]+1) >= Lengths[d + 1]){*/
+        if((I[d]+1) >= Lengths[d]){
           break;
         }
       }
@@ -71,7 +76,7 @@
 
 
 void refreshsamplingphy(int *Dim, int* I, double *Times, double *rtimes,
-                        int *Lengths, double *MinTime, int *MinL,
+                        int *Lengths, int *D, double *MinTime, int *MinL,
                         int *Samplings, int *rNum)
 {
   int d, i;
@@ -84,11 +89,14 @@
   for(i = 0; rtimes[i] < *MinTime; i++) {
     rtimes[i + 1] = rtimes[i];
     for(d = 0; d < *Dim; d++) {
-      while(I[d] < (Lengths[d + 1] - 1)){
+      /*while(I[d] < (Lengths[d + 1] - 1)){*/
+      while(I[d] < (Lengths[d] - 1)){
         I[d]++;
-        if(Times[Lengths[d] * d + I[d]] > rtimes[i]){
+        /*if(Times[Lengths[d] * d + I[d]] > rtimes[i]){*/
+        if(Times[D[d] + I[d]] > rtimes[i]){
           Samplings[(*MinL + 1) * d + (i + 1)] = I[d] + 1;
-          Tmp = Times[Lengths[d] * d + I[d]];
+          /*Tmp = Times[Lengths[d] * d + I[d]];*/
+          Tmp = Times[D[d] + I[d]];
           if(rtimes[i + 1] < Tmp){
             rtimes[i + 1] = Tmp; 
           }
@@ -101,9 +109,11 @@
   *rNum = i + 1;
   
   for(d = 0; d < *Dim; d++) {
-    while(I[d] < (Lengths[d + 1] -1)){
+    /*while(I[d] < (Lengths[d + 1] -1)){*/
+    while(I[d] < (Lengths[d] -1)){
       I[d]++;
-      if(Times[Lengths[d] * d + I[d]] > rtimes[i]){
+      /*if(Times[Lengths[d] * d + I[d]] > rtimes[i]){*/
+      if(Times[D[d] + I[d]] > rtimes[i]){
         Samplings[(*MinL + 1) * d + (i + 1)] = I[d] + 1;
         break;
       }
@@ -312,53 +322,53 @@
 
 
 void HYcrosscorr(int *gridL, int *xL, int *yL, double *grid, double *xtime,
-                 double *ytime, double *tmptime, double *dX, double *dY, 
+                 double *ytime, double *tmptime, double *dX, double *dY,
                  double *xvol, double *yvol, double *value)
 {
-  int i, j, I, J;
-  double A, B, C, s;
-  
-  for(i = 0; i < *gridL; i++){
+    int i, j, I, J;
+    double A, B, C, s;
     
-    for(j = 0; j < *yL; j++){
-      tmptime[j] = ytime[j] + grid[i];
-    }
-    
-    I = 0;
-    J = 0;
-    
-    /* Checking Starting Point */
-    while((I < (*xL-1)) && (J < (*yL-1))){
-        if(xtime[I] >= tmptime[J + 1]){
-            J++;
-        }else if(xtime[I + 1] <= tmptime[J]){
-            I++;
-        }else{
-            break;
+    for(i = 0; i < *gridL; i++){
+        
+        for(j = 0; j < *yL; j++){
+            tmptime[j] = ytime[j] + grid[i];
         }
-    }
-    
-    /* Main Component */
-    while((I < (*xL-1)) && (J < (*yL-1))) {
-        value[i] += dX[I] * dY[J];
-        if(xtime[I + 1] > tmptime[J + 1]){
-            J++;
-        }else if(xtime[I + 1] < tmptime[J + 1]){
-            I++;
-        }else{
-            I++;
-            J++;
+        
+        I = 0;
+        J = 0;
+        
+        /* Checking Starting Point */
+        while((I < (*xL-1)) && (J < (*yL-1))){
+            if(xtime[I] >= tmptime[J + 1]){
+                J++;
+            }else if(xtime[I + 1] <= tmptime[J]){
+                I++;
+            }else{
+                break;
+            }
         }
+        
+        /* Main Component */
+        while((I < (*xL-1)) && (J < (*yL-1))) {
+            value[i] += dX[I] * dY[J];
+            if(xtime[I + 1] > tmptime[J + 1]){
+                J++;
+            }else if(xtime[I + 1] < tmptime[J + 1]){
+                I++;
+            }else{
+                I++;
+                J++;
+            }
+        }
+        
+        /* Positive semi-definite correction */
+        A = (*xvol)*(*xvol) + value[i]*value[i];
+        B = (*xvol + *yvol)*value[i];
+        C = (*yvol)*(*yvol) + value[i]*value[i];
+        
+        s = sqrt(A*C-B*B);
+        
+        value[i] = B/sqrt((A + s)*(C + s));
+        
     }
-    
-    /* Positive semi-definite correction */
-    A = (*xvol)*(*xvol) + value[i]*value[i];
-    B = (*xvol + *yvol)*value[i];
-    C = (*yvol)*(*yvol) + value[i]*value[i];
-    
-    s = sqrt(A*C-B*B);
-    
-    value[i] = B/sqrt((A + s)*(C + s));
-    
-  }
-}
+}
\ No newline at end of file



More information about the Yuima-commits mailing list