Click here to Skip to main content
15,881,852 members
Articles / Programming Languages / C#

Windows Development in C++, COM API Clients

Rate me:
Please Sign up or sign in to vote.
4.98/5 (31 votes)
3 Jan 2015CPOL7 min read 62.7K   1.6K   106  
Using the Facade Pattern to simplify development with COM based APIs
#include "stdafx.h"

#include "hnum_pdsp_defs.h"

namespace harlinn
{
    namespace numerics
    {
        namespace SuperLU
        {
            namespace Double
            {

                void
                pdgstrf_pruneL(
	                       const int  jcol,      /* current column */
	                       const int  *perm_r,   /* row pivotings */
	                       const int  pivrow,    /* pivot row of column jcol */
	                       const int  nseg,      /* number of U-segments */
	                       const int  *segrep,   /* in */
	                       const int  *repfnz,   /* in */
	                       int        *xprune,   /* modified */
	                       int        *ispruned, /* modified */
	                       GlobalLU_t *Glu /* modified - global LU data structures */
	                       )
                {
                /*
                 * -- SuperLU MT routine (version 1.0) --
                 * Univ. of California Berkeley, Xerox Palo Alto Research Center,
                 * and Lawrence Berkeley National Lab.
                 * August 15, 1997
                 *
                 * Purpose
                 * =======
                 *   Reduces the L-structure of those supernodes whose L-structure
                 *   contains the current pivot row "pivrow".
                 *
                 */
                    register int jsupno, irep, isupno, irep1, kmin, kmax, krow;
                    register int i, ktemp;
                    register int do_prune; /* logical variable */
                    int        *xsup, *xsup_end, *supno;
                    int        *lsub, *xlsub, *xlsub_end;

                    xsup       = Glu->xsup;
                    xsup_end   = Glu->xsup_end;
                    supno      = Glu->supno;
                    lsub       = Glu->lsub;
                    xlsub      = Glu->xlsub;
                    xlsub_end  = Glu->xlsub_end;
    
                    /*
                     * For each supernode-rep irep in U[*,j]
                     */
                    jsupno = supno[jcol];
                    for (i = 0; i < nseg; i++) {

	                irep = segrep[i];
	                irep1 = irep + 1;

	                /* Don't prune with a zero U-segment */
 	                if ( repfnz[irep] == EMPTY ) continue;

     	                /* If a supernode overlaps with the next panel, then the U-segment 
   	                 * is fragmented into two parts - irep and irep1. We should let
	                 * pruning occur at the rep-column in irep1's supernode. 
	                 */
	                isupno = supno[irep];
	                if ( isupno == supno[irep1] ) continue;	/* Don't prune */

	                /*
	                 * If it is not pruned & it has a nonz in row L[pivrow,i]
	                 */
	                do_prune = FALSE;
	                if ( isupno != jsupno ) {
	                    if ( ! ispruned[irep] ) {
		                kmin = SINGLETON( isupno ) ? xlsub_end[irep] : xlsub[irep];
		                kmax = xprune[irep] - 1;
		                for (krow = kmin; krow <= kmax; krow++) 
		                    if ( lsub[krow] == pivrow ) {
			                do_prune = TRUE;
			                break;
		                    }
	                    }
	    
    	                    if ( do_prune ) {

	     	                /* Do a quicksort-type partition */
	                        while ( kmin <= kmax ) {
	    	                    if ( perm_r[lsub[kmax]] == EMPTY ) 
			                kmax--;
		                    else if ( perm_r[lsub[kmin]] != EMPTY )
			                kmin++;
		                    else { /* kmin below pivrow, and kmax above pivrow: 
		                            * 	interchange the two subscripts
			                    */
		                        ktemp = lsub[kmin];
		                        lsub[kmin] = lsub[kmax];
		                        lsub[kmax] = ktemp;
		                        kmin++;
		                        kmax--;
		                    }
	                        } /* while */

	                        xprune[irep] = kmin;	/* Pruning */
		                ispruned[irep] = 1;

                #ifdef CHK_PRUNE
                if (irep >= LOCOL && irep >= HICOL && jcol >= LOCOL && jcol <= HICOL)	
                    printf("pdgstrf_pruneL() for irep %d using col %d: xprune %d - %d\n", 
	                   irep, jcol, xlsub[irep], kmin);
                #endif
	                    } /* if do_prune */

	                } /* if */

                    } /* for each U-segment... */
                }

            };
        };
    };
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Sea Surveillance AS
Norway Norway
Chief Architect - Sea Surveillance AS.

Specializing in integrated operations and high performance computing solutions.

I’ve been fooling around with computers since the early eighties, I’ve even done work on CP/M and MP/M.

Wrote my first “real” program on a BBC micro model B based on a series in a magazine at that time. It was fun and I got hooked on this thing called programming ...

A few Highlights:

  • High performance application server development
  • Model Driven Architecture and Code generators
  • Real-Time Distributed Solutions
  • C, C++, C#, Java, TSQL, PL/SQL, Delphi, ActionScript, Perl, Rexx
  • Microsoft SQL Server, Oracle RDBMS, IBM DB2, PostGreSQL
  • AMQP, Apache qpid, RabbitMQ, Microsoft Message Queuing, IBM WebSphereMQ, Oracle TuxidoMQ
  • Oracle WebLogic, IBM WebSphere
  • Corba, COM, DCE, WCF
  • AspenTech InfoPlus.21(IP21), OsiSoft PI


More information about what I do for a living can be found at: harlinn.com or LinkedIn

You can contact me at espen@harlinn.no

Comments and Discussions