Exemple #1
0
void TestCppTools::Quantity_test()
{
    Length length1(1.);
    Length length2(length1 * 5);
    Length length3;
    length3 = length2;
    //qDebug() << length1 << length2;

    QCOMPARE(sizeof(Length), sizeof(double));
}
int compareto(char *p, char *q)
{
	int i = 0,count=0,l1=0,l2=0;
	l1 = length1(p);
	l2 = length1(q);

	if (l1 != l2||l1==0)
		return 0;
	else
	{
		while (*(p + i) != '\0')
		{
			if (*(p + i) != (*(q + i)))
				count++;
			i++;
		}
		if (count == 0)
			return 1;
		else
			return 0;
	}
}
Exemple #3
0
void f(int capacity_, char *old_storage)
{
  try {
      length1();
      int old_capacity = capacity_;
      capacity_ *= 2;
      g(capacity_);
      for (int i = 1; i < old_capacity; i++)
	old_storage[i] = old_storage[i - 1];
  } catch (...) {
      for (int i = 1; i < capacity_; i++){old_storage[i] = 0;}
  }
}
Exemple #4
0
void TestStyles::testCopyParagraphStyle()
{
    QTextLength length1(QTextLength::FixedLength, 10.0);
    QTextLength length2(QTextLength::FixedLength, 20.0);
    QTextLength length3(QTextLength::FixedLength, 30.0);

    KoParagraphStyle style1;
    KoParagraphStyle style2;
    style2.setParentStyle(&style1);

    style1.setLeftMargin(length1);
    style1.setRightMargin(length3);
    style2.setRightMargin(length2);

    KoParagraphStyle newStyle;
    newStyle.copyProperties(&style2);
    QCOMPARE(newStyle.leftMargin(), 10.0);
    QCOMPARE(newStyle.rightMargin(), 20.0);
}
Exemple #5
0
void
MDS_Embedding::classicalScaling( const MDS_Matrix& D )
{

  int N = D.length0();
  int n = length1();

  MDS_Matrix A,B,H(N,N);

  // Matrix A
  // Since we assume the D_{ik} now to be the
  // Euclidian distances, we have to square them.
  // a_{rs} = -1/2 D_{rs}*D_{rs}

  A = -0.5*D.pointMul(D);

  // Matrix H
  // This is not very effective, but
  // done for the ease of the implementation.

  H = -1./double(N);
  H.diagonal() = 1.-1./double(N);

  // Matrix B
  // Inner-product-matrix, B=XX^T

  B = H*A*H;

  // Jacobi rotation:
  // Compute eigenvalues and eigenvectors of B.

  MDS_Matrix	V(N,N);
  MDS_Vector	lambda( N );
  int		rot;

  jacobid(  B.nr(), N, lambda.nr() , V.nr(), &rot );
  eigsrtd( lambda.nr() , V.nr(), N );

  copy( V.window(0,0,N,n) );
}
Exemple #6
0
void TestStyles::testApplyParagraphStyleWithParent()
{
    KoParagraphStyle style1;
    style1.setStyleId(1002);
    KoParagraphStyle style2;
    style2.setStyleId(1003);
    KoParagraphStyle style3;
    style3.setStyleId(1004);

    style3.setParentStyle(&style2);
    style2.setParentStyle(&style1);

    style1.setAlignment(Qt::AlignRight);
    QCOMPARE(style1.alignment(), Qt::AlignRight);
    QCOMPARE(style2.alignment(), Qt::AlignRight);
    QCOMPARE(style3.alignment(), Qt::AlignRight);

    style2.setAlignment(Qt::AlignCenter);
    QCOMPARE(style1.alignment(), Qt::AlignRight);
    QCOMPARE(style2.alignment(), Qt::AlignCenter);
    QCOMPARE(style3.alignment(), Qt::AlignCenter);

    style3.setAlignment(Qt::AlignLeft | Qt::AlignAbsolute);
    QCOMPARE(style1.alignment(), Qt::AlignRight);
    QCOMPARE(style2.alignment(), Qt::AlignCenter);
    QCOMPARE(style3.alignment(), Qt::AlignLeft | Qt::AlignAbsolute);

    style3.setLineSpacing(23.45);
    style3.setLineHeightPercent(150);
    style3.setLineHeightAbsolute(8.0);
    QCOMPARE(style3.lineHeightPercent(), 0.0);
    QCOMPARE(style3.lineHeightAbsolute(), 8.0);
    QCOMPARE(style3.lineSpacing(), 23.45);
    QVERIFY(!style3.hasNormalLineHeight());

    style3.setNormalLineHeight();
    QCOMPARE(style3.lineHeightPercent(), 0.0);
    QCOMPARE(style3.lineHeightAbsolute(), 0.0);
    QCOMPARE(style3.lineSpacing(), 0.0);
    QVERIFY(style3.hasNormalLineHeight());

    style3.setLineHeightPercent(150);
    style3.setLineSpacing(56.78);
    QCOMPARE(style3.lineHeightPercent(), 150.0);
    QCOMPARE(style3.lineHeightAbsolute(), 0.0);
    QCOMPARE(style3.lineSpacing(), 56.78);
    QVERIFY(!style3.hasNormalLineHeight());

    QTextLength length0(QTextLength::FixedLength, 0.0);
    QTextLength length1(QTextLength::FixedLength, 10.0);
    QTextLength length2(QTextLength::FixedLength, 20.0);

    style1.setLeftMargin(length1);
    QCOMPARE(style1.leftMargin(), 10.0);
    QCOMPARE(style2.leftMargin(), 10.0);
    QCOMPARE(style3.leftMargin(), 10.0);
    style2.setRightMargin(length2);
    QCOMPARE(style1.rightMargin(), 0.0);
    QCOMPARE(style2.rightMargin(), 20.0);
    QCOMPARE(style3.rightMargin(), 20.0);

    // now actually apply it.
    QTextBlockFormat rawFormat;
    style1.applyStyle(rawFormat);
    KoParagraphStyle format(rawFormat, rawFormat.toCharFormat());
    QCOMPARE(rawFormat.properties().count(), 4);
    QCOMPARE(format.alignment(), Qt::AlignRight);
    QCOMPARE(rawFormat.property(KoParagraphStyle::StyleId).toInt(), 1002);
    //since we have not specified any NextStyle it should be the same as the current style
    QCOMPARE(rawFormat.property(KoParagraphStyle::StyleId).toInt(), rawFormat.property(KoParagraphStyle::NextStyle).toInt());
    QCOMPARE(format.leftMargin(), 10.0);
    QCOMPARE(format.rightMargin(), 0.0);

    style2.applyStyle(rawFormat);
    KoParagraphStyle format2(rawFormat, rawFormat.toCharFormat());
    QCOMPARE(rawFormat.properties().count(), 5);
    QCOMPARE(format2.alignment(), Qt::AlignCenter);
    QCOMPARE(rawFormat.property(KoParagraphStyle::StyleId).toInt(), 1003);
    //since we have not specified any NextStyle it should be the same as the current style
    QCOMPARE(rawFormat.property(KoParagraphStyle::StyleId).toInt(), rawFormat.property(KoParagraphStyle::NextStyle).toInt());
    QCOMPARE(format2.leftMargin(), 10.0);
    QCOMPARE(format2.rightMargin(), 20.0);

    style3.applyStyle(rawFormat);
    KoParagraphStyle format3(rawFormat, rawFormat.toCharFormat());
    QCOMPARE(rawFormat.properties().count(), 9);
    QCOMPARE(rawFormat.property(KoParagraphStyle::LineSpacing).toReal(), 56.78);
    QCOMPARE(format3.alignment(), Qt::AlignLeft | Qt::AlignAbsolute);
    QCOMPARE(rawFormat.property(KoParagraphStyle::StyleId).toInt(), 1004);
    //since we have not specified any NextStyle it should be the same as the current style
    QCOMPARE(rawFormat.property(KoParagraphStyle::StyleId).toInt(), rawFormat.property(KoParagraphStyle::NextStyle).toInt());
    QCOMPARE(format3.leftMargin(), 10.0);
    QCOMPARE(format3.rightMargin(), 20.0);
}
Exemple #7
0
int main(int argc, char *argv[]) {
	int i, s;
	list q;
	list1 q1;
	list2 q2;
	record d;
	personal f;
	record *ptr, *pt;
	personal *ptr2, *pt2;
	FILE *fp, *fp1, *fp2, *fp3, *fp4, *fp6, *fp8, *fp9, *fp10;
	fp1 = fopen("b.txt", "a+");
	node2 *st2;
	init(&q);
	init1(&q1);
	init2(&q2);
	char a[48];
	char br[32];
	int m, posi, choice, roll, size, s1, s2, s3, s4, num, posii, yr, MIS;
	while(1) {
		choice = printmenu();
		switch(choice) {
			case 1 :
				printf("\nEnter the Name, MIS, Branch, Year of student and the MIS before which you wish to insert the record :\n");  /*if it is the first record 'posi' can be anything*/
				scanf(" %[^\n]%d%s%d%d", a, &m, br, &yr, &posi);
				fp = fopen("k.txt", "a+");
				Add_academic(&q, a, m, br, posi, yr, fp);
				fclose(fp);
				print(&q);
				break;
			case 2 :
				printf("Enter the MIS of the student record to be deleted :\n");
				scanf("%d", &posii);
				fp = fopen("k.txt", "a+");
				fp4 = fopen("d.txt", "w+");
				if(pt = delet_academic(&q, posii,fp,fp4)) {
					printf("Name:%s\n MIS:%d\n Branch:%s\n Year :%d\n", pt->name, pt->MIS, pt->branch, pt->year);
				}
				else {
					printf("INVALID ENTRY\n");
				}
				print(&q);
				fclose(fp);
				fclose(fp4);
				break;
			case 3 :
				printf("Enter the MIS of student :\n");
				scanf("%d", &roll);
				if(ptr = search(&q, roll)) {

					printf("\nName :%s\tMIS :%d\tBranch :%s\tYear :%d\n", ptr->name, ptr->MIS, ptr->branch, ptr->year);

				}
				else {

					printf("\nRECORD NOT FOUND\n");
				}
				break;
			case 4 :
				printf("Enter the Name, MIS, Branch, Year of student :\n");
				scanf(" %[^\n]%d%s%d", a, &m, br, &yr);
				fp = fopen("k.txt", "a+");
				append_academic(&q, a, m, br, yr, fp);
				print(&q);
				fclose(fp);
				break;
			case 5 :
				size = length(&q);
				printf("Number of student records(academic) : %d\n", size);
				break;
			case 6 :
				printf("Enter the MIS of student :\n");
				scanf("%d", &roll);
				creatingID(&q, roll);
				break;
			case 7 :
				fp = fopen("k.txt", "a+");
				fp3 = fopen("a.txt", "r");
				academicfromfile(&q, fp3, fp);
				print(&q);
				fclose(fp);
				fclose(fp3);
				break;
			case 8 :
				printf("Enter the Name, MIS, Branch and Year of student:\n");
				scanf(" %[^\n]%d%s%d", a, &m, br, &yr);  /*MIS should be same*/
				fp = fopen("k.txt", "a+");
				fp6 = fopen("n.txt", "w+");
				Modify_academic(&q, m, a, br, yr, fp, fp6); 
				print(&q);
				fclose(fp);
				fclose(fp6);
				break;
			case 9 :
				num = length1(&q1);
				printf("No of students who appeared for final exam : %d\n", num);
				break;
			case 10 :
				printf("Enter MIS, T1 marks of 4 subjects ,MIS before which you wish to enter the record and the semester :\n");
				scanf("%d%d%d%d%d%d%d",&roll,&s1,&s2,&s3,&s4,&m, &i);
				T1Marks(&q1,roll,s1,s2,s3,s4,m,i); 
				printT1(&q1, i);
				break;	
			case 11 :
				printf("Enter MIS and T2 marks of 4 subjects and the semester :\n");
				scanf("%d%d%d%d%d%d",&roll,&s1,&s2,&s3,&s4, &i);
				T2Marks(&q1,roll,s1,s2,s3,s4,i);
				printT2(&q1, i);
				break;
			case 12 :
				printf("Enter MIS and ESE marks of 4 subjects and the semester :\n");
				scanf("%d%d%d%d%d%d",&roll,&s1,&s2,&s3,&s4,&i);
				ESEMarks(&q1,roll,s1,s2,s3,s4,i);
				printESE(&q1, i);
				break;
			case 13 :
				printf("Enter the MIS and the semester :\n");
				scanf("%d%d", &MIS, &i);
				Total(&q1, MIS,i, fp1);
				printTOT(&q1, i);
				break;
			case 14 :
				printf("Enter the Name, MIS, Mobile no., Email Id of student and the MIS before which you wish to insert the record :\n");  /*if it is the first record, posi can be anything*/
				scanf(" %[^\n]%d%d%s%d", a, &m, &yr, br, &posi);
				fp2 = fopen("c.txt", "a+");
				Add2_personal(&q2, a, m, yr, br, posi, fp2);
				print2(&q2);
				fclose(fp2);
				break;
			case 15 : 
				printf("Enter the MIS of the student record to be deleted :\n");
				scanf("%d", &posii);
				fp2 = fopen("c.txt", "a+");
				fp9 = fopen("s.txt", "w+");
				if(pt2 = delet2_personal(&q2, posii,fp2, fp9)) {
					printf("Name:%s\n MIS:%d\n Mobile No:%d\n Email Id :%s\n", pt2->name, pt2->MISS, pt2->mobile, pt2->email_Id);
				}
				else {
					printf("INVALID ENTRY\n");
				}
				print2(&q2);
				fclose(fp2);
				fclose(fp9);
				break;
			case 16 :
				printf("Enter the MIS of student :\n");
				scanf("%d", &roll);
				if(ptr2 = search2(&q2, roll)) {

					printf("\nName :%s\tMIS :%d\tMobile No :%d\tEmail Id :%s\n", ptr2->name, ptr2->MISS, ptr2->mobile, ptr2->email_Id);
				}
				else {

					printf("\nRECORD NOT FOUND\n");
				}
				break;	
			case 17 :
				printf("Enter the Name, MIS, Mobile no. and Email Id of student:\n");
				scanf(" %[^\n]%d%d%s", a, &m, &yr, br);  /*MIS should be same*/
				fp8 = fopen("w.txt", "w+");
				fp2 = fopen("c.txt", "a+");
				Modify2_personal(&q2, m, a, yr, br,fp2, fp8);
				print2(&q2);
				fclose(fp2);
				fclose(fp8);
				break;
			case 18 :
				printf("\nEnter the MIS of the student and the semester :\n");
				scanf("%d%d", &m, &s);
				link(&q, &q1, &q2, m, s);
				break;
			case 19 :
				fp2 = fopen("c.txt", "a+");
				fp10 = fopen("p.txt", "r");
				personalfromfile(&q2, fp10, fp2);
				print2(&q2);
				fclose(fp2);
				fclose(fp10);
				break;
			case 20 :
				fclose(fp1);
				exit(1);
				break;
		}
	}
}