예제 #1
0
파일: alg2d.c 프로젝트: restrepo/micrOMEGAs
void alg2_recommon_n(Term a2)
	{
    List m2l,l,l1,nl;
    int cnum,n,d;
	m2l=CompoundArgN(a2,5);
    nl=NewList();
	l=m2l;
	if(is_empty_list(l))
		return;


	while(!is_empty_list(l))
		{
        nl=AppendLast(nl,CompoundArg1(ListFirst(l)));
		l=ListTail(l);
		}

	cnum=gcf_list(nl);
	if(IntegerValue(ListFirst(nl))<0)
		cnum*=-1;
    if(cnum==1)
        {
        RemoveList(nl);
        return;
        }

    l1=m2l;
	l=nl;
	while(!is_empty_list(l))
		{
        SetCompoundArg(ListFirst(l1),1,
            NewInteger(IntegerValue(ListFirst(l))/cnum));
		l=ListTail(l);
		l1=ListTail(l1);
		}

	RemoveList(nl);
    n=IntegerValue(CompoundArg1(CompoundArg2(a2)));
    d=IntegerValue(CompoundArg2(CompoundArg2(a2)));
    n*=cnum;
    cnum=gcf(n,d);
    n/=cnum;
    d/=cnum;
    SetCompoundArg(CompoundArg2(a2),1,NewInteger(n));
    SetCompoundArg(CompoundArg2(a2),2,NewInteger(d));

	return ;
	}
예제 #2
0
파일: gcf-tool.c 프로젝트: Meijuh/ltsmin
int main(int argc, char *argv[]){
    HREinitBegin(argv[0]);
    HREaddOptions(options,"Tool for creating and extracting GCF archives\n\nOperations");
    HREinitStart(&argc,&argv,0,-1,NULL,"<operation> <arguments>");
    compression_policy=SSMcreateSWP(gcf_policy);
    coding_policy=SSMcreateSWP(zip_policy);
    switch(operation){
    case GCF_CREATE:
        gcf_create();
        break;
    case GCF_EXTRACT:
        gcf_extract();
        break;
     case GCF_LIST:
        gcf_list();
        break;
    case GCF_COPY:
        gcf_copy();
        break;
    case GCF_COMPRESS:
        gcf_compress();
        break;
    case GCF_DECOMPRESS:
        gcf_decompress();
        break;
    case GCF_TO_ZIP:
        gcf_copy_zip();
        break;
    case ZIP_TO_GCF:
        zip_copy_gcf();
        break;
    default:
        Abort("Illegal arguments, type gcf -h for help");
    }
    HREexit(EXIT_SUCCESS);
}
예제 #3
0
파일: alg2d.c 프로젝트: restrepo/micrOMEGAs
void alg2_common_n(Term a2)
	{
	List m2l,l,l1,nl,dl;
	int cnum,cden,ti;
	m2l=CompoundArgN(a2,5);
	nl=dl=NewList();
	l=m2l;
	if(is_empty_list(l))
		return;


	while(!is_empty_list(l))
		{
		Term t;
		t=ConsumeCompoundArg(ListFirst(l),1);
		nl=AppendLast(nl,CompoundArg1(t));
		dl=AppendLast(dl,CompoundArg2(t));
		FreeAtomic(t);
		l=ListTail(l);
		}

	cnum=gcf_list(nl);
	cden=gcf_list(dl);
	if(IntegerValue(ListFirst(nl))<0)
		cnum*=-1;
	
	l=nl;
	l1=dl;
	while(!is_empty_list(l))
		{
		ChangeList(l,NewInteger(IntegerValue(ListFirst(l))/cnum));
		ChangeList(l1,NewInteger(IntegerValue(ListFirst(l1))/cden));
		l=ListTail(l);
		l1=ListTail(l1);
		}

	ti=mlt_list1(dl);

	l=nl;
	l1=dl;
	while(!is_empty_list(l))
		{
		ChangeList(l,
			NewInteger(IntegerValue(ListFirst(l))*ti/IntegerValue(ListFirst(l1))));
		l=ListTail(l);
		l1=ListTail(l1);
		}

	cden*=ti;
	ti=gcf_list(nl);
	cnum*=ti;

	l=nl;
	while(!is_empty_list(l))
		{
		ChangeList(l,NewInteger(IntegerValue(ListFirst(l))/ti));
		l=ListTail(l);
		}

	ti=gcf(cnum,cden);
	cnum/=ti;
	cden/=ti;
	RemoveList(dl);

	SetCompoundArg(a2,2,MakeCompound2(OPR_DIV,NewInteger(cnum),NewInteger(cden)));
	l=m2l;
	l1=nl;

	while(!is_empty_list(l))
		{
		SetCompoundArg(ListFirst(l),1,ListFirst(l1));
		l1=ListTail(l1);
		l=ListTail(l);
		}
	RemoveList(nl);

	return ;
	}