Click here to Skip to main content
15,883,883 members
Articles / Desktop Programming / Win32

Stopwatch

Rate me:
Please Sign up or sign in to vote.
4.97/5 (29 votes)
3 Jan 2015CPOL6 min read 66K   1.5K   43  
Benchmark C++ std::vector vs raw arrays, move assignable/constructable & copy assignable/constructable
#include "stdafx.h"

#include <math.h>
#include "hnum_slu_dcomplex.h"
#include "hnum_slu_mt_Cnames.h"

namespace harlinn
{
    namespace numerics
    {
        namespace SuperLU
        {
            int izmax1_(int *n, doublecomplex *cx, int *incx)
            {
            /*  -- LAPACK auxiliary routine (version 2.0) --   
                    Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,   
                    Courant Institute, Argonne National Lab, and Rice University   
                    September 30, 1994   


                Purpose   
                =======   

                IZMAX1 finds the index of the element whose real part has maximum   
                absolute value.   

                Based on IZAMAX from Level 1 BLAS.   
                The change is to use the 'genuine' absolute value.   

                Contributed by Nick Higham for use with ZLACON.   

                Arguments   
                =========   

                N       (input) INT   
                        The number of elements in the vector CX.   

                CX      (input) COMPLEX*16 array, dimension (N)   
                        The vector whose elements will be summed.   

                INCX    (input) INT   
                        The spacing between successive values of CX.  INCX >= 1.   

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

                /* System generated locals */
                int ret_val, i__1, i__2;
                double d__1;
    
                /* Local variables */
                double smax;
                int i, ix;

            #define CX(I) cx[(I)-1]

                ret_val = 0;
                if (*n < 1) {
	            return ret_val;
                }
                ret_val = 1;
                if (*n == 1) {
	            return ret_val;
                }
                if (*incx == 1) {
	            goto L30;
                }

            /*     CODE FOR INCREMENT NOT EQUAL TO 1 */

                ix = 1;
                smax = (d__1 = CX(1).r, fabs(d__1));
                ix += *incx;
                i__1 = *n;
                for (i = 2; i <= *n; ++i) {
	            i__2 = ix;
	            if ((d__1 = CX(ix).r, fabs(d__1)) <= smax) {
	                goto L10;
	            }
	            ret_val = i;
	            i__2 = ix;
	            smax = (d__1 = CX(ix).r, fabs(d__1));
            L10:
	            ix += *incx;
            /* L20: */
                }
                return ret_val;

            /*     CODE FOR INCREMENT EQUAL TO 1 */

            L30:
                smax = (d__1 = CX(1).r, fabs(d__1));
                i__1 = *n;
                for (i = 2; i <= *n; ++i) {
	            i__2 = i;
	            if ((d__1 = CX(i).r, fabs(d__1)) <= smax) {
	                goto L40;
	            }
	            ret_val = i;
	            i__2 = i;
	            smax = (d__1 = CX(i).r, fabs(d__1));
            L40:
	            ;
                }
                return ret_val;

            /*     End of IZMAX1 */

            } /* izmax1_ */

        };
    };
};

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