Exemplo n.º 1
0
        inline void TestSwapClass() {
            TTest i(0);
            TTest j(1);

            DoSwap(i, j);

            UNIT_ASSERT_EQUAL(i.Val, 1);
            UNIT_ASSERT_EQUAL(j.Val, 0);
        }
Exemplo n.º 2
0
        inline void TestSwapPrimitive() {
            int i = 0;
            int j = 1;

            DoSwap(i, j);

            UNIT_ASSERT_EQUAL(i, 1);
            UNIT_ASSERT_EQUAL(j, 0);
        }
Exemplo n.º 3
0
void Fsm::Swap(Fsm& fsm)
{
	DoSwap(m_transitions, fsm.m_transitions);
	DoSwap(initial, fsm.initial);
	DoSwap(m_final, fsm.m_final);
	DoSwap(letters, fsm.letters);
	DoSwap(determined, fsm.determined);
	DoSwap(outputs, fsm.outputs);
	DoSwap(tags, fsm.tags);
	DoSwap(isAlternative, fsm.isAlternative);
}
Exemplo n.º 4
0
TVector<TFeatureInteraction> CalcFeatureInteraction(const TVector<TInternalFeatureInteraction>& internalFeatureInteraction,
                                                          const TFeaturesLayout& layout) {
    THashMap<std::pair<int, int>, double> sumInteraction;
    double totalEffect = 0;

    for (const auto& effectWithFeaturePair : internalFeatureInteraction) {
        TVector<TFeature> features{effectWithFeaturePair.FirstFeature, effectWithFeaturePair.SecondFeature};

        TVector<TVector<int>> internalToRegular;
        for (const auto& internalFeature : features) {
            TVector<int> regularFeatures;
            if (internalFeature.Type == ESplitType::FloatFeature) {
                regularFeatures.push_back(layout.GetFeature(internalFeature.FeatureIdx, EFeatureType::Float));
            } else {
                auto proj = internalFeature.Ctr.Base.Projection;
                for (auto& binFeature : proj.BinFeatures) {
                    regularFeatures.push_back(layout.GetFeature(binFeature.FloatFeature, EFeatureType::Float));
                }
                for (auto catFeature : proj.CatFeatures) {
                    regularFeatures.push_back(layout.GetFeature(catFeature, EFeatureType::Categorical));
                }
            }
            internalToRegular.push_back(regularFeatures);
        }

        double effect = effectWithFeaturePair.Score;
        for (int f0 : internalToRegular[0]) {
            for (int f1 : internalToRegular[1]) {
                if (f0 == f1) {
                    continue;
                }
                if (f1 < f0) {
                    DoSwap(f0, f1);
                }
                sumInteraction[std::make_pair(f0, f1)] += effect / (internalToRegular[0].ysize() * internalToRegular[1].ysize());
            }
        }
        totalEffect += effect;
    }

    TVector<TFeatureInteraction> regularFeatureEffect;
    for (const auto& pairInteraction : sumInteraction) {
        int f0 = pairInteraction.first.first;
        int f1 = pairInteraction.first.second;
        regularFeatureEffect.push_back(
            TFeatureInteraction(sumInteraction[pairInteraction.first] / totalEffect * 100, layout.GetFeatureType(f0),
                                layout.GetInternalFeatureIdx(f0),
                                layout.GetFeatureType(f1), layout.GetInternalFeatureIdx(f1)));
    }

    Sort(regularFeatureEffect.rbegin(), regularFeatureEffect.rend(), [](const TFeatureInteraction& left, const TFeatureInteraction& right) {
        return left.Score < right.Score;
    });
    return regularFeatureEffect;
}
Exemplo n.º 5
0
Arquivo: svm32.c Projeto: drudru/cel
int singleStep (VM32Cpu * cpu)
{
    unsigned char inst;
    unsigned char * ptr;
    
    /* Get an instruction */
    ptr = (char *) cpu->pc;
    inst = *ptr;
    
    switch (inst) {
	/* Standard Op Codes */
	case 0x00: DoBreak(cpu);
	    break;
	case 0x01: DoNothing(cpu);
	    break;
	case 0x02: DoCall(cpu);
	    break;
	case 0x03: DoPushZero(cpu);
	    break;
	case 0x04: DoPushImmediateNative(cpu);
	    break;
	case 0x05: DoReturn(cpu);
	    break;
	case 0x06: DoPop(cpu);
	    break;
	case 0x07: DoSwap(cpu);
	    break;
	case 0x08: DoSetupFrame(cpu);
	    break;
	case 0x09: DoRestoreFrame(cpu);
	    break;
	case 0x0a: CallNative(cpu);
	    break;
	case 0x0b: DoPushSelf(cpu);
	    break;
	case 0x0c: DoCheckArgCount(cpu);
	    break;
	case 0x0d: DoBranch(cpu);
	    break;
	case 0x0e: DoBranchIfTrue(cpu);
	    break;
	case 0x0f: DoBranchIfFalse(cpu);
	    break;
	default:
	    DoInvalidInstruction(cpu);
	    break;
    }
    return 0;
}
Exemplo n.º 6
0
int
main(int, char **)
{
	printf("IsBigEndian: %s\n", (IsBigEndian()) ? "yes" : "no");
	printf("IsBigEndian2: %s\n", (IsBigEndian2()) ? "yes" : "no");

	printDouble(1.0);
	printDouble(0.0);
	printDouble(12345.6789);
	ReconstructDouble(12345.6789);
	ReconstructDouble(123401234.567891234);
	double val = 123401234.567891234;

	printInt(1);
	printInt(0x10000);

	printf("Swap test\n");
	printDouble(val);
	DoSwap(val);
	printDouble(val);
	
	return 0;
}
Exemplo n.º 7
0
void TOptsParser::Swap(TOptsParser& that) {
    DoSwap(Opts_, that.Opts_);
    DoSwap(Argc_, that.Argc_);
    DoSwap(Argv_, that.Argv_);
    DoSwap(TempCurrentOpt_, that.TempCurrentOpt_);
    DoSwap(ProgramName_, that.ProgramName_);
    DoSwap(Pos_, that.Pos_);
    DoSwap(Sop_, that.Sop_);
    DoSwap(Stopped_, that.Stopped_);
    DoSwap(CurrentOpt_, that.CurrentOpt_);
    DoSwap(CurrentValue_, that.CurrentValue_);
    DoSwap(GotMinusMinus_, that.GotMinusMinus_);
    DoSwap(OptsSeen_, that.OptsSeen_);
}
Exemplo n.º 8
0
int main( int argc, char **argv)
{
/*  sample command lines
-i bdv.bshort -o junk.bshort -V -# 16
*/
	OSErr   error = noErr;
	static  char id[] = "$Revision: 1.2 $$Date: 2002/09/10 22:06:02 $";
	char    headerName[ NAME_SIZE ];
	char    *extension;
	char    ofName[ NAME_SIZE ];
	int     OutOrder;

	error = ProcessCommandLine( argc, argv );
	ILError( error, "error in command line" );

	extension = strrchr( u.InFileName, '.' );
	if( !strlen(extension) ) {
		printf( "Input file name error\n" );
		return 0;
	}
	if( !equalString( extension, ".bfloat" )) {
		printf( "This utility works only on bfloat images!\n" );
		return 0;
	}

//	strcpy( headerName, u.InFileName, NAME_SIZE );
	strcpy( headerName, u.InFileName ); //zrinka 09/10/02
	
	extension = strrchr( headerName, '.' );
	if( !strlen(extension) ) {
		printf( "Input file name error\n" );
		return 0;
	}
	sprintf( extension, ".hdr" );
	u.inFile = errfopen( headerName, "r" );
	
	fscanf( u.inFile, "%d%d%d%d", &u.id.ys, &u.id.xs, &u.id.zs, &u.id.ByteOrder );
//	error = ck_fclose( u.inFile, "input header" );
	error = ck_fclose( u.inFile ); //zrinka 09/10/02
	
	u.inFile  =  errfopen( u.InFileName,  "rb" );

	strcpy( ofName, u.OutFileName );
	strcat( ofName, ".bfloat" );
	u.outFile =  errfopen( ofName, "wb" );

	error = DoSwap( u.inFile, u.outFile );
	ILError( error, argv[0] );

	error = ck_fclose( u.inFile );
	ILError( error, "infile" );

	error = ck_fclose( u.outFile );
	ILError( error, "infile" );

	strcpy( ofName, u.OutFileName );
	strcat( ofName, ".hdr" );
	u.outFile = errfopen( ofName, "w" );
	if( u.id.ByteOrder == 1 ) {	// pc-dec bytOrder
		OutOrder = 0;
	} else {
		OutOrder = 1;
	}

	fprintf( u.outFile, "%d %d %d %d", u.id.ys, u.id.xs, u.id.zs, OutOrder );
	error = ck_fclose( u.outFile );
	ILError( error, "main" );
}