PLearn 0.1
qld_interface.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // qld_interface.cc
00004 //
00005 // Copyright (C) 2005 ApSTAT Technologies Inc. 
00006 // 
00007 // Redistribution and use in source and binary forms, with or without
00008 // modification, are permitted provided that the following conditions are met:
00009 // 
00010 //  1. Redistributions of source code must retain the above copyright
00011 //     notice, this list of conditions and the following disclaimer.
00012 // 
00013 //  2. Redistributions in binary form must reproduce the above copyright
00014 //     notice, this list of conditions and the following disclaimer in the
00015 //     documentation and/or other materials provided with the distribution.
00016 // 
00017 //  3. The name of the authors may not be used to endorse or promote
00018 //     products derived from this software without specific prior written
00019 //     permission.
00020 // 
00021 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
00022 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00023 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
00024 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00025 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00026 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00027 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00028 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00029 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031 // 
00032 // This file is part of the PLearn library. For more information on the PLearn
00033 // library, go to the PLearn Web site at www.plearn.org
00034 
00035 /* *******************************************************      
00036  * $Id: qld_interface.cc 6351 2006-10-25 19:05:45Z chapados $ 
00037  ******************************************************* */
00038 
00039 // Authors: Nicolas Chapados
00040 
00043 #include "qld_interface.h"
00044 #include "math.h"
00045 
00046 // From PLearn
00047 #include <plearn/math/TMat_maths.h>
00048 
00049 namespace PLearn {
00050 using namespace std;
00051 
00052 void qld_interface(
00053     Mat A,                       
00054     Vec B,                       
00055     int ME,                      
00056     Mat C,                       
00057     Vec D,                       
00058     Vec XL,                      
00059     Vec XU,                      
00060     int& iout,                   
00061     int& ifail,                  
00062     int& iprint,                 
00063     Vec& X,                      
00064     Vec& U,                      
00065     Vec WAR,                     
00066     TVec<int> IWAR               
00067     )
00068 {
00069     int M = A.length();
00070     int N = A.width();
00071 
00072     PLASSERT( M >= 1 && N >= 1 );
00073     PLASSERT( M == B.length() );
00074     PLASSERT( N == C.width()  &&  N == C.length() );
00075     PLASSERT( N == D.length() );
00076     PLASSERT( N == XL.length() && N == XU.length() );
00077   
00078     int MMAX  = max(M,1);
00079     int NMAX  = N;
00080     int MNN   = M + N + N;
00081     int LWAR  = 3 * NMAX * NMAX/2 + 10*NMAX + 2*(MMAX+1);
00082     int LIWAR = N;
00083 
00084     // In this first version, transpose matrix A
00085     Mat Atrans = transpose(A);
00086     X.resize(N);
00087     U.resize(MNN);
00088     WAR.resize(LWAR);
00089     IWAR.resize(LIWAR);
00090     IWAR[0] = 0;                   // QLD performs Cholesky itself
00091     double eps = DBL_EPSILON;
00092 
00093     ql0001_(&M,          &ME,       &MMAX,
00094             &N,          &NMAX,     &MNN,
00095             C.data(),    D.data(),  Atrans.data(),
00096             B.data(),    XL.data(), XU.data(),
00097             X.data(),    U.data(),
00098             &iout,       &ifail,    &iprint,
00099             WAR.data(),  &LWAR,
00100             IWAR.data(), &LIWAR,
00101             &eps);
00102 }
00103 
00104 
00105 } // end of namespace PLearn
00106 
00107 
00108 /*
00109   Local Variables:
00110   mode:c++
00111   c-basic-offset:4
00112   c-file-style:"stroustrup"
00113   c-file-offsets:((innamespace . 0)(inline-open . 0))
00114   indent-tabs-mode:nil
00115   fill-column:79
00116   End:
00117 */
00118 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines