Click here to Skip to main content
15,887,083 members
Articles / Multimedia / DirectX

Rendering Text with Direct2D & DirectWrite

Rate me:
Please Sign up or sign in to vote.
4.94/5 (39 votes)
3 Jan 2015CPOL8 min read 106K   2.8K   76  
Direct2D, DirectWrite, Windows API, C++, std::shared_ptr and more
#include "stdafx.h"

/*
 * -- SuperLU routine (version 2.0) --
 * Lawrence Berkeley National Lab, Univ. of California Berkeley,
 * and Xerox Palo Alto Research Center.
 * September 10, 2007
 *
 */
/*
 * File name:	claqgs.c
 * History:     Modified from LAPACK routine CLAQGE
 */
#include <math.h>
#include "hnum_pcsp_defs.h"


/*
    Purpose   
    =======   

    claqgs() equilibrates a general sparse M by N matrix A using the row and   
    scaling factors in the vectors R and C.   

    See supermatrix.h for the definition of 'SuperMatrix' structure.

    Arguments   
    =========   

    A       (input/output) SuperMatrix*
            On exit, the equilibrated matrix.  See EQUED for the form of 
            the equilibrated matrix. The type of A can be:
	    Stype = SLU_NC; Dtype = SLU_C; Mtype = SLU_GE.
	    
    R       (input) float*, dimension (A->nrow)
            The row scale factors for A.
	    
    C       (input) float*, dimension (A->ncol)
            The column scale factors for A.
	    
    ROWCND  (input) float
            Ratio of the smallest R(i) to the largest R(i).
	    
    COLCND  (input) float
            Ratio of the smallest C(i) to the largest C(i).
	    
    AMAX    (input) float
            Absolute value of largest matrix entry.
	    
    EQUED   (output) equed_t*
            Specifies the form of equilibration that was done.   
            = NOEQUIL: No equilibration
            = ROW:  Row equilibration, i.e., A has been premultiplied by
                    diag(R).   
            = COL:  Column equilibration, i.e., A has been postmultiplied
                    by diag(C).   
            = BOTH: Both row and column equilibration, i.e., A has been
                    replaced by diag(R) * A * diag(C).   

    Internal Parameters   
    ===================   

    THRESH is a threshold value used to decide if row or column scaling   
    should be done based on the ratio of the row or column scaling   
    factors.  If ROWCND < THRESH, row scaling is done, and if   
    COLCND < THRESH, column scaling is done.   

    LARGE and SMALL are threshold values used to decide if row scaling   
    should be done based on the absolute size of the largest matrix   
    element.  If AMAX > LARGE or AMAX < SMALL, row scaling is done.   

    ===================================================================== 
*/

#ifdef small
#undef small
#endif

namespace harlinn
{
    namespace numerics
    {
        namespace SuperLU
        {
            namespace Complex
            {
                void claqgs(SuperMatrix *A, float *r, float *c, float rowcnd, float colcnd, float amax, equed_t *equed)
                {

                #define THRESH    (0.1)
    
                    /* Local variables */
                    NCformat *Astore;
                    complex   *Aval;
                    int i, j, irow;
                    float large, small, cj;
                    
                    float temp;


                    /* Quick return if possible */
                    if (A->nrow <= 0 || A->ncol <= 0) {
	                *equed = NOEQUIL;
	                return;
                    }

                    Astore = (NCformat*)A->Store;
                    Aval = (complex*)Astore->nzval;
    
                    /* Initialize LARGE and SMALL. */
                    small = slamch_("Safe minimum") / slamch_("Precision");
                    large = 1. / small;

                    if (rowcnd >= THRESH && amax >= small && amax <= large) {
	                if (colcnd >= THRESH)
	                    *equed = NOEQUIL;
	                else {
	                    /* Column scaling */
	                    for (j = 0; j < A->ncol; ++j) {
		                cj = c[j];
		                for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; ++i) {
		                    cs_mult(&Aval[i], &Aval[i], cj);
                                }
	                    }
	                    *equed = COL;
	                }
                    } else if (colcnd >= THRESH) {
	                /* Row scaling, no column scaling */
	                for (j = 0; j < A->ncol; ++j)
	                    for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; ++i) {
		                irow = Astore->rowind[i];
		                cs_mult(&Aval[i], &Aval[i], r[irow]);
	                    }
	                *equed = ROW;
                    } else {
	                /* Row and column scaling */
	                for (j = 0; j < A->ncol; ++j) {
	                    cj = c[j];
	                    for (i = Astore->colptr[j]; i < Astore->colptr[j+1]; ++i) {
		                irow = Astore->rowind[i];
		                temp = cj * r[irow];
		                cs_mult(&Aval[i], &Aval[i], temp);
	                    }
	                }
	                *equed = BOTH;
                    }

                    return;

                } /* claqgs */

            };
        };
    };
};            

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