posts - 81, comments - 262, trackbacks - 0

Wednesday, November 14, 2012

Crashplan and Volume Shadow Copy Errors (Fixed)

For the longest time I have been logging Volume Shadow Copy (VSS) errors in my Windows Application log every few seconds. I use Crashplan to back up my machine online – other than those errors I have been very happy with it. I didn't have much luck trying to fix the error previously and have been living with it until I stumbled upon the fix.

When cleaning up space on C:\, I noticed the Crashplan cache was consuming a lot of space (9 GB on an SSD in my case). I moved the cache to the backup drive (a 3 TB USB 3 attached disk) and the errors ceased. Surprise!

If you have a log full of VSS errors try moving your Crashplan cache to another drive. You can change the location by editing the node cachepath in ProgramData\CrashPlan\conf\my.service.xml. In my case I have it on the same drive as the backup destinations (\temp\cache). Be sure to cycle the crash plan service for the change to take.


Some useful links on the error


The VSS errors which I was receiving:



Volume Shadow Copy Service error: Error calling a routine on the Shadow Copy Provider {b5946137-7b9f-4925-af80-51abd60b20d5}. Routine returned E_INVALIDARG. Routine details GetSnapshot({00000000-0000-0000-0000-000000000000},0000000000358EB0).


Get Shadow Copy Properties


Execution Context: Coordinator

posted @ Wednesday, November 14, 2012 4:12 PM | Feedback (15) |

Modified False Position Method in C++ Accepting a Function Pointer

The modified false position method is fairly straightforward to implement. The method is described in most numerical methods texts in easily translatable pseudo code. The method requires evaluating the function during the solution process, requiring in a naïve implementation hard coding of the function being solved.

Function pointers can be used to pass a general function to the method, so that one implementation can be used to solve various functions. In particular, member function pointers can be used to root solve a function for one of many independent variables. Consider for example, f(x,a), where you would like to find x such that f(x,a) = 0 for a particular value of a.

One solution is to define a function g(x) = f(x,a) in a class, using a from a class member, then use the solver to solve g(x)=0. The class is used to contain the fixed independent variables so that a function pointer with one argument can be passed to the solver.

Being somewhat new to C++ myself, getting this to work took some research into member function pointers. My implementation is included below. To use it, one would, in a class, define a function which has an argument of double and returns a double using member variables to evaluate the function given a particular x. Then in the class create a member function pointer to the function being solved.

For example one could use the solver in a class "TranscendentalSolver" with a double fTranscendental(double x) member function like so:


double (TranscendentalSolver::*f)(double) = &TranscendentalSolver::fTranscendental;


// use a modified false position solver to solve the transcendental

b = ModFalsePos(f, *this, xLeft, xRight, 1E-15, 1E-15, 100, verbose);


My implementation of the modified false position method is listed below. Note: I modified it to use bisection in the case when the new root is out of bounds (an issue I had solving atan).






#include <cstdio>

#include <math.h>



// Modified False Position Method, for details

// see p 129 in Numerical Methods by Chapra.

// f - function pointer to the function to find a root

// xl - lower x bound

// xu - upper x bound

// es - relative stopping error

// et - stopping error (abs(f(xr)) < et)

// imax - maximum iterations

// verbose - whether to print information to cout


// This is a templated Function so that a member function pointer

// may be passed. This is very useful when the function has

// several arguments, but only one is being varied. Then the

// caller may define a member function, using class members to

// find the other parameters.

template<typename F>

double ModFalsePos(double (F::*f)(double), F & obj,

        double xl, double xu, double es, double et, int imax,

        bool verbose)


    // the current iteration

    int iter = 0;


    // lower and upper iteration counts,

    // used to detect when one of the bounds

    // is 'stuck'.

    int il = 0;

    int iu = 0;


    // the current root

    double xr = 0;


    // the current error estimate

    double ea = 0;


    // the lower function value

    double fl = (obj.*f)(xl);


    // the upper function value

    double fu = (obj.*f)(xu);


    if (verbose)


        printf("xl = %12.4e, xu = %12.4e\n", xl, xu);


                "Iter.", "x_l", "x_u", "x_r", "f(x_r)", "ea");






        // new root estimate and function value

        double xrold = xr;

        xr = xu - fu * (xl - xu) / (fl - fu);



        // if out of bounds - false position

        // has failed, use bisection

        if ( xr > xu || xr < xl )


            xr = (xl+xu)/2;




        double fr = (obj.*f)(xr);


        // iteration counter increment

        iter += 1;


        // error estimate (relative)

        if (xr != 0 )

            ea = std::abs((xr-xrold)/xr)*100;


        // test signs

        double test = fl*fr;


        if (test < 0)


            xu = xr;

            fu = (obj.*f)(xu);

            iu = 0;

            il += 1;

            if (il >= 2)

                fl = fl / 2;



        else if (test > 0)


            xl = xr;

            fl = (obj.*f)(xl);

            il = 0;

            iu += 1;

            if (iu >= 2)

                fu = fu /2;





            ea = 0;






                    iter, xl, xu, xr, fr, ea);



        if (ea < es || std::abs(fr) < et || iter >= imax)





    return xr;





posted @ Wednesday, November 14, 2012 11:32 AM | Feedback (0) | Filed Under [ Technical Computing ]

Powered by:
Powered By Subtext Powered By ASP.NET