Exemplo n.º 1
0
		std::string makeFormattedString(
		const char* aFormat,
		const A1& a1 = A1(),
		const A2& a2 = A2(),
		const A3& a3 = A3(),
		const A4& a4 = A4(),
		const A5& a5 = A5(),
		const A6& a6 = A6(),
		const A7& a7 = A7(),
		const A8& a8 = A8(),
		const A9& a9 = A9(),
		const A10& a10 = A10(),
		const A11& a11 = A11(),
		const A12& a12 = A12(),
		const A13& a13 = A13(),
		const A14& a14 = A14(),
		const A15& a15 = A15(),
		const A16& a16 = A16(),
		const A17& a17 = A17(),
		const A18& a18 = A18(),
		const A19& a19 = A19(),
		const A20& a20 = A20()
		)
		{
			return makeStringByPrintf(aFormat,
				a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
				a11, a12, a13, a14, a15, a16, a17, a18, a19, a20
				);
		}
Exemplo n.º 2
0
int main(){
  TTableContext Context;
  // create scheme
  Schema AnimalS;
  AnimalS.Add(TPair<TStr,TAttrType>("Animal", atStr));
  AnimalS.Add(TPair<TStr,TAttrType>("Size", atStr));
  AnimalS.Add(TPair<TStr,TAttrType>("Location", atStr));
  AnimalS.Add(TPair<TStr,TAttrType>("Number", atInt));
  TIntV RelevantCols;
  RelevantCols.Add(0);
  RelevantCols.Add(1);
  RelevantCols.Add(2);
  // create table
  PTable T = TTable::LoadSS("Animals", AnimalS, "tests/animals.txt", Context, RelevantCols);
  //PTable T = TTable::LoadSS("Animals", AnimalS, "animals.txt");
  T->Unique("Animal");
  TTable Ts = *T;  // did we fix problem with copy-c'tor ?
  //PTable Ts = TTable::LoadSS("Animals_s", AnimalS, "../../testfiles/animals.txt", RelevantCols);
  //Ts->Unique(AnimalUnique);

  // test Select
  // create predicate tree: find all animals that are big and african or medium and Australian
  TPredicate::TAtomicPredicate A1(atStr, true, EQ, "Location", "", 0, 0, "Africa");  
  TPredicate::TPredicateNode N1(A1);  // Location == "Africa"
  TPredicate::TAtomicPredicate A2(atStr, true, EQ, "Size", "", 0, 0, "big");  
  TPredicate::TPredicateNode N2(A2);  // Size == "big"
  TPredicate::TPredicateNode N3(AND);
  N3.AddLeftChild(&N1);
  N3.AddRightChild(&N2);
  TPredicate::TAtomicPredicate A4(atStr, true, EQ, "Location", "", 0, 0, "Australia");  
  TPredicate::TPredicateNode N4(A4);  
  TPredicate::TAtomicPredicate A5(atStr, true, EQ, "Size", "", 0, 0, "medium");  
  TPredicate::TPredicateNode N5(A5); 
  TPredicate::TPredicateNode N6(AND);
  N6.AddLeftChild(&N4);
  N6.AddRightChild(&N5);
  TPredicate::TPredicateNode N7(OR);
  N7.AddLeftChild(&N3);
  N7.AddRightChild(&N6);
  TPredicate Pred(&N7);
  TIntV SelectedRows;
  Ts.Select(Pred, SelectedRows);

  TStrV GroupBy;
  GroupBy.Add("Location");
  T->Group(GroupBy, "LocationGroup");
  GroupBy.Add("Size");
  T->Group(GroupBy, "LocationSizeGroup");
  T->Count("LocationCount", "Location");
  PTable Tj = T->Join("Location", Ts, "Location");
  TStrV UniqueAnimals;
  UniqueAnimals.Add("Animals_1.Animal");
  UniqueAnimals.Add("Animals_2.Animal");
  Tj->Unique(UniqueAnimals, false);
  //print table
   T->SaveSS("tests/animals_out_T.txt");
   Ts.SaveSS("tests/animals_out_Ts.txt");
   Tj->SaveSS("tests/animals_out_Tj.txt");
  return 0;
}
int hpx_main(boost::program_options::variables_map& vm)
{
    {
        orthotope<double>
            A0({3, 3})
          , A1({3, 3})
          , A2({3, 3})  
          , A3({3, 3})
          , A4({3, 3})
          , A5({4, 4})
            ;
    
        // QR {{1, 3, 6}, {3, 5, 7}, {6, 7, 4}}
        A0.row(0,  1,    3,    6   );
        A0.row(1,  3,    5,    7   );
        A0.row(2,  6,    7,    4   );
    
        // QR {{12, -51, 4}, {6, 167, -68}, {-4, 24, -41}}
        A1.row(0,  12,  -51,   4   );
        A1.row(1,  6,    167, -68  );
        A1.row(2, -4,    24,  -41  );
 
        // QR {{2, -2, 18}, {2, 1, 0}, {1, 2, 0}}
        A2.row(0,  2,   -2,    18  );
        A2.row(1,  2,    1,    0   );
        A2.row(2,  1,    2,    0   );
   
        // QR {{0, 1, 1}, {1, 1, 2}, {0, 0, 3}}
        A3.row(0,  0,    1,    1   );
        A3.row(1,  1,    1,    2   );
        A3.row(2,  0,    0,    3   );

        // QR {{1, 1, -1}, {1, 2, 1}, {1, 2, -1}}
        A4.row(0,  1,    1,   -1   );
        A4.row(1,  1,    2,    1   );
        A4.row(2,  1,    2,   -1   );
    
        // QR {{4, -2, 2, 8}, {-2, 6, 2, 4}, {2, 2, 10, -6}, {8, 4, -6, 12}}
        A5.row(0,  4,   -2,    2,    8   );
        A5.row(1, -2,    6,    2,    4   );
        A5.row(2,  2,    2,    10,  -6   );
        A5.row(3,  8,    4,   -6,    12  );
    
        householders(A0);
        householders(A1);
        householders(A2);
        householders(A3);
        householders(A4);
        householders(A5);
    }

    return hpx::finalize(); 
}
Exemplo n.º 4
0
int main()
{
	int n = 0, a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, num = 0;
	int count_a1 = 0, count_a2 = 0, count_a3 = 0, count_a4 = 0, count_a5 = 0;
	int flag_A2 = 1;

	scanf("%d", &n);
	for (; n > 0; n--) {
		scanf("%d", &num);
		A1(num, &a1, &count_a1);
		A2(num, &a2, &count_a2, &flag_A2);
		A3(num, &a3, &count_a3);
		A4(num, &a4, &count_a4);
		A5(num, &a5, &count_a5);
	}
	if (count_a1 > 0)
		printf("%d ", a1);
	else
		printf("N ");

	if (count_a2 > 0)
		printf("%d ", a2);
	else
		printf("N ");

	if (count_a3 > 0)
		printf("%d ", a3);
	else
		printf("N ");

	if (count_a4 > 0)
		printf("%.1lf ", (double)a4 / count_a4);
	else
		printf("N ");

	if (count_a5 > 0)
		printf("%d", a5);
	else
		printf("N");

	return 0;
}
Exemplo n.º 5
0
int main(int argc, char** argv) {
	const int TARIFFA = 2;
	
	Autovettura A1("bj066mx", "benzina", "suv", 6);
	Autovettura A2("kt887gg", "gpl", "monovolume", 5);
	Autovettura A3("dh572xc", "metano", "berlina", 5);
	Autovettura A4("mq111nd", "diesel", "utilitaria", 4);
	Autobus A5("cc789oi", "benzina", "bus", 50, "Milano", 200);
	Autobus A6("st230ks", "gpl", "bus", 50, "Roma", 300);
	Autobus A7("vv234sd", "metano", "bus", 25, "Napoli", 100);
	Autobus A8("we785ss", "diesel", "bus", 60, "Parma", 400);
	
	Autoveicolo * v[8];
	v[0] = &A1;
	v[1] = &A2;
	v[2] = &A3;
	v[3] = &A4;
	v[4] = &A5;
	v[5] = &A6;
	v[6] = &A7;
	v[7] = &A8;
	
	cout<<"Polimorfismo:\n";
	for(int i=0; i<8; i++) {
		v[i]->stampaDati();
		cout << "\n";
	}
	
	
	Coda C1, C2, C3;
	C1.append(&A1);
	C1.append(&A2);
	C1.append(&A3);
	C1.append(&A4);
	C1.append(&A5);
	C1.append(&A6);
	C1.append(&A7);
	C1.append(&A8);
	
	C2.append(&A1);
	C2.append(&A2);
	C2.append(&A3);
	C2.append(&A4);
	C2.append(&A5);
	C2.append(&A6);
	C2.append(&A7);
	
	C3.append(&A1);
	C3.append(&A2);
	C3.append(&A3);
	C3.append(&A4);
	C3.append(&A5);
	C3.append(&A6);
	
	
	
	cout<<"\n\n\nCoda1:\n";
	cout<<C1;
	cout<<"\n\n\nCoda2:\n";
	cout<<C2;
	cout<<"\n\n\nCoda3:\n";
	cout<<C3;
	cout<<"\n\n\n";
	
	int e1, e2, e3;
	e1 = C1.getNelem();
	e2 = C2.getNelem();
	e3 = C3.getNelem();
	
	for(int i = 0; i<e1; i++) {
		Autoveicolo * elem;
		C1.pop(elem, TARIFFA); 
		cout<<"Elemento rimosso -> ";
		elem->stampaDati();
		cout<<endl;
	}
	cout<<"\n\n\n";
	for(int i = 0; i<e2; i++) {
		Autoveicolo * elem;
		C2.pop(elem, TARIFFA); 
		cout<<"Elemento rimosso -> ";
		elem->stampaDati();
		cout<<endl;
	}
	cout<<"\n\n\n";
	for(int i = 0; i<e3; i++) {
		Autoveicolo * elem;
		C3.pop(elem, TARIFFA); 
		cout<<"Elemento rimosso -> ";
		elem->stampaDati();
		cout<<endl;
	}
	if(C1.getIncasso()>100) {
		cout<<"\n\n\nIncasso totale: "<<C1.getIncasso()<< " bombe!";
	} else {
		cout<<"\n\n\nIncasso totale: "<<C1.getIncasso()<<" frecce!";
	}
	
	return 0;
}
Exemplo n.º 6
0
            blit(muertebmp,enemigom,0,0,0,0,33,33);//carga la imagen sobre el buffer pacman
            draw_sprite(buffer,enemigom,_x,_y);
            blit(buffer, screen ,0,0,0,0,1280,600);
            rest(80);

        _x = 0;
        _y = 0;
        vidaenemigo--;
    }
}

int main()
{

    allegro_init();
    install_keyboard();

    set_color_depth(32);
    set_gfx_mode(GFX_AUTODETECT_WINDOWED,1280, 600 , 0, 0);

    //inicializa la musica en allegro
    if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0)
        {
            allegro_message("Error: inicializando sistema de sonido\n%s\n", allegro_error);
            return 1;
        }
    // ajuste de volumen
    set_volume(70, 70);//cuanto se oye a la izquierdsa y a la derecha

    intro = load_wav("music/start.wav");
    sirenafantasma = load_wav("music/sirene.wav");
    muertes = load_wav("music/muerte.wav");

    buffer = create_bitmap(1280,600); //870 570
    pacman = create_bitmap(33,33);
    complemento = create_bitmap(400,600);
    vid =create_bitmap(33,33);
    ataqueb = create_bitmap(33,33);

    atabmp = load_bitmap("images/ataque.bmp",NULL);
    roca = load_bitmap("images/tile2.bmp",NULL);
    pacbmp =load_bitmap("images/tank2.bmp", NULL);
    comida = load_bitmap("images/Comida.bmp",NULL);
    muertebmp = load_bitmap("images/muerte1.bmp",NULL);
    combmp =load_bitmap("images/complemento.bmp",NULL);
    vidas = load_bitmap("images/vidas.bmp",NULL);

    mapa1 mapa;
    enemigo A1(30*1,30*18) ;
    enemigo A2(30*27,30*1) ;
    enemigo A3(30*14,30*11) ;
    enemigo A4(30*27,30*18) ;
    enemigo A5(30*27,30*18);
    personaje1 personaje;
    personaje2 personaje3;



    play_sample(intro,200,150,1000,0); // volumen,sonido,,velocidad a la que se reproduce,distribucion 1000 es punto medio,para que no se repita
    rest(4000);

    play_sample(sirenafantasma,150,150,1000,1);

    while (!key[KEY_ESC] && mapa.game_over())
    {
        if(A1.getvida()==0 && A2.getvida()==0 && A3.getvida()==0 && A4.getvida()==0) return false;

        personaje.mover_personaje();
        mapa.dibujar_mapa();
        personaje.dibujar_personaje();
        personaje.ataque();
        personaje.ataque1();
        personaje3.dibujar_personaje();
        personaje3.mover_personaje();
        A1.mover_enemigo();
        A2.mover_enemigo();
        A4.mover_enemigo();
        A3.mover_enemigo();
        personaje3.ataque();
        personaje3.ataque1();
        A1.ataque2();
        A1.ataque_enemigo();
        A2.ataque2();
        A2.ataque_enemigo();
        A4.ataque2();
        A4.ataque_enemigo();
        A3.ataque2();
        A3.ataque_enemigo();
        A1.muerte_enemigo();
        A2.muerte_enemigo();
Exemplo n.º 7
0
SolidesP	ConstruireNormale (FacesP Face)
// Construit un solide symbolisant la normale à la face.
// Le solide est placé sur le barycentre de la face et peut donc
// être hors de la face.
// Sa longueur est égale à 5% de la dimension du solide à laquelle la
// face appartient s'il existe. Sinon, c'est 10 % de la dimension de la face.
{
	SolidesP	Sol = Face.Solide () ;

	double	HauteurTot ;

	Englobants3D	EnglobantFace = Face.Englobant () ;

	if (Sol.EstInitialise ()) {
		Englobants3D	E = Sol.Englobant () ;
		Vecteurs3D		V (E.BasGauche (),E.HautDroit ()) ;
		HauteurTot = 0.05*V.Norme () ; ;
	}
	else {
		Vecteurs3D		V (EnglobantFace.BasGauche (),EnglobantFace.HautDroit ()) ;
		HauteurTot = 0.1*V.Norme () ; ;
	}

	double	LargeurPied = HauteurTot / 24,
            LargeurTete = HauteurTot / 4,
            HauteurPied = (7./8.)*HauteurTot ;

	// Construction d'un repère centré sur le "barycentre" de la face, dont
	// le (xOy) correspond au plan de la face et dont le z est la normale à
	// la face.
	Points3D	Origine = 0.5*(EnglobantFace.BasGauche ()+EnglobantFace.HautDroit ()) ;

	Vecteurs3D	K = Face.VecteurNormal ().VecteurNorme (),
				U (Face.ContourExterieur ().IemeAreteOrientee (0).Origine ().Point3D (),
				Face.ContourExterieur ().IemeAreteOrientee (0).Extremite ().Point3D ()),
				I = (K & U).VecteurNorme (),
				J = (K & I).VecteurNorme () ;

	SommetsP	S1 (Origine-LargeurPied/2*I - LargeurPied/2*J) ;
	SommetsP	S2 (Origine-LargeurPied/2*I + LargeurPied/2*J) ;
	SommetsP	S3 (Origine+LargeurPied/2*I + LargeurPied/2*J) ;
	SommetsP	S4 (Origine+LargeurPied/2*I - LargeurPied/2*J) ;
	SommetsP	S5 (Origine-LargeurPied/2*I - LargeurPied/2*J + HauteurPied*K) ;
	SommetsP	S6 (Origine-LargeurPied/2*I + LargeurPied/2*J + HauteurPied*K) ;
	SommetsP	S7 (Origine+LargeurPied/2*I + LargeurPied/2*J + HauteurPied*K) ;
	SommetsP	S8 (Origine+LargeurPied/2*I - LargeurPied/2*J + HauteurPied*K) ;
	SommetsP	S9 (Origine-LargeurTete/2*I - LargeurTete/2*J + HauteurPied*K) ;
	SommetsP	S10 (Origine-LargeurTete/2*I + LargeurTete/2*J + HauteurPied*K) ;
	SommetsP	S11 (Origine+LargeurTete/2*I + LargeurTete/2*J + HauteurPied*K) ;
	SommetsP	S12 (Origine+LargeurTete/2*I - LargeurTete/2*J + HauteurPied*K) ;
	SommetsP	S13 (Origine+HauteurTot*K) ;

	AretesP	A1 (S1,S2) ;
	AretesP	A2 (S2,S3) ;
	AretesP	A3 (S3,S4) ;
	AretesP	A4 (S4,S1) ;
	AretesP	A5 (S5,S6) ;
	AretesP	A6 (S6,S7) ;
	AretesP	A7 (S7,S8) ;
	AretesP	A8 (S8,S5) ;
	AretesP	A9 (S9,S10) ;
	AretesP	A10 (S10,S11) ;
	AretesP	A11 (S11,S12) ;
	AretesP	A12 (S12,S9) ;
	AretesP	A13 (S1,S5) ;
	AretesP	A14 (S2,S6) ;
	AretesP	A15 (S3,S7) ;
	AretesP	A16 (S4,S8) ;
	AretesP	A17 (S9,S13) ;
	AretesP	A18 (S10,S13) ;
	AretesP	A19 (S11,S13) ;
	AretesP	A20 (S12,S13) ;

	Listes <AretesP>	L1 ;
	L1.InsertionEnQueue (A1) ;
	L1.InsertionEnQueue (A2) ;
	L1.InsertionEnQueue (A3) ;
	L1.InsertionEnQueue (A4) ;

	Listes <AretesP>	L2 ;
	L2.InsertionEnQueue (A1) ;
	L2.InsertionEnQueue (A13) ;
	L2.InsertionEnQueue (A5) ;
	L2.InsertionEnQueue (A14) ;

	Listes <AretesP>	L3 ;
	L3.InsertionEnQueue (A2) ;
	L3.InsertionEnQueue (A14) ;
	L3.InsertionEnQueue (A6) ;
	L3.InsertionEnQueue (A15) ;

	Listes <AretesP>	L4 ;
	L4.InsertionEnQueue (A3) ;
	L4.InsertionEnQueue (A15) ;
	L4.InsertionEnQueue (A7) ;
	L4.InsertionEnQueue (A16) ;

	Listes <AretesP>	L5 ;
	L5.InsertionEnQueue (A4) ;
	L5.InsertionEnQueue (A16) ;
	L5.InsertionEnQueue (A8) ;
	L5.InsertionEnQueue (A13) ;

	Listes <AretesP>	L6 ;
	L6.InsertionEnQueue (A9) ;
	L6.InsertionEnQueue (A10) ;
	L6.InsertionEnQueue (A11) ;
	L6.InsertionEnQueue (A12) ;

	Listes <AretesP>	L7 ;
	L7.InsertionEnQueue (A8) ;
	L7.InsertionEnQueue (A7) ;
	L7.InsertionEnQueue (A6) ;
	L7.InsertionEnQueue (A5) ;

	Listes <AretesP>	L8 ;
	L8.InsertionEnQueue (A9) ;
	L8.InsertionEnQueue (A17) ;
	L8.InsertionEnQueue (A18) ;

	Listes <AretesP>	L9 ;
	L9.InsertionEnQueue (A10) ;
	L9.InsertionEnQueue (A18) ;
	L9.InsertionEnQueue (A19) ;

	Listes <AretesP>	L10 ;
	L10.InsertionEnQueue (A11) ;
	L10.InsertionEnQueue (A19) ;
	L10.InsertionEnQueue (A20) ;

	Listes <AretesP>	L11 ;
	L11.InsertionEnQueue (A12) ;
	L11.InsertionEnQueue (A20) ;
	L11.InsertionEnQueue (A17) ;

	Listes <FacesP>	ListeFaces ;
	AttributsFaces	*PAF = new AttributsFaces (PMateriauRouge) ;
	FacesP F1 (ContoursP (L1),PAF) ;
	ListeFaces.InsertionEnQueue (F1) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L2),PAF)) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L3),PAF)) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L4),PAF)) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L5),PAF)) ;
	ContoursP C (L6) ;
	FacesP	F (C,PAF) ;
	F.AjouterContourInterieur (ContoursP (L7)) ;
	ListeFaces.InsertionEnQueue (F) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L8),PAF)) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L9),PAF)) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L10),PAF)) ;
	ListeFaces.InsertionEnQueue (FacesP (ContoursP (L11),PAF)) ;

	return SolidesP (ListeFaces) ;
}
Exemplo n.º 8
0
void ConstructA_CG2(const mesh& Mesh, FullMatrix& A)
{
  const int NumPhysElems = Mesh.get_NumPhysElems();
  const int NumBndNodes  = Mesh.get_SubNumBndNodes();
  const int Asize = Mesh.get_SubNumPhysNodes();

  assert_eq(Asize,A.get_NumRows());
  assert_eq(Asize,A.get_NumCols());
  
  dTensor1 A1(6);
  dTensor1 A2(6);
  dTensor1 A3(6);
  dTensor1 A4(6);
  dTensor1 A5(6);
  dTensor1 A6(6);

  A1.set(1, -oneninth     );
  A1.set(2,  4.0*oneninth );
  A1.set(3, -oneninth     );
  A1.set(4,  4.0*oneninth );
  A1.set(5,  4.0*oneninth );
  A1.set(6, -oneninth     );
  
  A2.set(1, -onethird     );
  A2.set(2,  0.0          );
  A2.set(3,  onethird     );
  A2.set(4, -4.0*onethird );
  A2.set(5,  4.0*onethird );
  A2.set(6,  0.0          );
  
  A3.set(1, -onethird     );
  A3.set(2, -4.0*onethird );
  A3.set(3,  0.0          );
  A3.set(4,  0.0          );
  A3.set(5,  4.0*onethird );
  A3.set(6,  onethird     );
  
  A4.set(1,  4.0          );
  A4.set(2, -4.0          );
  A4.set(3,  0.0          );
  A4.set(4, -4.0          );
  A4.set(5,  4.0          );
  A4.set(6,  0.0          );

  A5.set(1,  2.0          );
  A5.set(2, -4.0          );
  A5.set(3,  2.0          );
  A5.set(4,  0.0          );
  A5.set(5,  0.0          );
  A5.set(6,  0.0          );
  
  A6.set(1,  2.0          );
  A6.set(2,  0.0          );
  A6.set(3,  0.0          );
  A6.set(4, -4.0          );
  A6.set(5,  0.0          );
  A6.set(6,  2.0          );

  dTensor2 spts(3,2);
  spts.set(1,1,  1.0/3.0 );
  spts.set(1,2, -1.0/6.0 );
  
  spts.set(2,1, -1.0/6.0 );
  spts.set(2,2, -1.0/6.0 );
  
  spts.set(3,1, -1.0/6.0 );
  spts.set(3,2,  1.0/3.0 );
  
  dTensor1 wgts(3);
  wgts.set(1, 1.0/6.0 );
  wgts.set(2, 1.0/6.0 );
  wgts.set(3, 1.0/6.0 );
  
  // Loop over all elements in the mesh
  for (int i=1; i<=NumPhysElems; i++)
    {
      // Information for element i
      iTensor1 tt(6);
      for (int k=1; k<=6; k++)
	{  tt.set(k, Mesh.get_node_subs(i,k) );  }
      
      // Evaluate gradients of the Lagrange polynomials on Gauss quadrature points      
      dTensor2 gpx(6,3);
      dTensor2 gpy(6,3);
      
      for (int m=1; m<=3; m++)
	{
	  double  xi = spts.get(m,1);
	  double eta = spts.get(m,2);
	  
	  for (int k=1; k<=6; k++)
	    {
	      double gp_xi  = A2.get(k) + 2.0*A5.get(k)*xi + A4.get(k)*eta;
	      double gp_eta = A3.get(k) + A4.get(k)*xi + 2.0*A6.get(k)*eta;

	      gpx.set(k,m, Mesh.get_jmat(i,1,1)*gp_xi
		         + Mesh.get_jmat(i,1,2)*gp_eta );
	      gpy.set(k,m, Mesh.get_jmat(i,2,1)*gp_xi
		         + Mesh.get_jmat(i,2,2)*gp_eta );
	    }
	}

      // Entries of the stiffness matrix A
      double Area = Mesh.get_area_prim(i);
      for (int j=1; j<=6; j++)
	for (int k=1; k<=6; k++)
	  {
	    double tmp = A.get(tt.get(j),tt.get(k));
	    for (int m=1; m<=3; m++)
	      {
		tmp = tmp + 2.0*Area*wgts.get(m)*(gpx.get(j,m)*gpx.get(k,m)+gpy.get(j,m)*gpy.get(k,m));
	      }
	    A.set(tt.get(j),tt.get(k), tmp );
	  }
    }

  // Replace boundary node equations by Dirichlet boundary condition enforcement
  for (int i=1; i<=NumBndNodes; i++)
    {
      const int j=Mesh.get_sub_bnd_node(i);
      
      for (int k=1; k<=A.get_NumCols(); k++)
	{
	  A.set(j,k, 0.0 );	  
	}
      for (int k=1; k<=A.get_NumRows(); k++)
	{
	  A.set(k,j, 0.0 );
	}
      A.set(j,j, 1.0 );
    }

  // Get sparse structure representation
  A.Sparsify();
  
}
Exemplo n.º 9
0
int		main(void)
{
	Bureaucrat	bob("bob", 45);
	Bureaucrat	jim("jim", 150);
	Bureaucrat	zac("zac", 2);
	Form		A4("A4", 45, 45);
	Form		A5("A5", 150, 21);
	ShrubberyCreationForm Creation("home");
	PresidentialPardonForm Pardon("Amedy Coulibaly");
	RobotomyRequestForm Robot("Zaz");

	try
	{
		Form a("fifi", 0, 2);
	}
	catch (std::exception const& e)
	{
		std::cout << "Form a: " << e.what() << std::endl;
	}
	try
	{
		Form b("fifi", 42, 151);
	}
	catch (std::exception const& e)
	{
		std::cout << "Form b: " << e.what() << std::endl;
	}
	std::cout << A4 << std::endl << A5 << std::endl << std::endl;
	std::cout << bob << std::endl << jim << std::endl << std::endl;
	try
	{
		A4.beSigned(jim);
	}
	catch (std::exception const& e)
	{
		std::cout << "Form A4: " << e.what() << std::endl;
	}
	std::cout << A4 << std::endl << std::endl;
	try
	{
		A4.beSigned(bob);
	}
	catch (std::exception const& e)
	{
		std::cout << "Form A4: " << e.what() << std::endl;
	}
	std::cout << A4 << std::endl << std::endl;
	bob.signForm(A4);
	bob.signForm(A5);
	jim.signForm(A4);
	jim.executeForm(Creation);
	bob.executeForm(Creation);
	zac.signForm(Pardon);
	zac.executeForm(Pardon);
	jim.executeForm(Pardon);
	zac.signForm(Robot);
	zac.executeForm(Robot);
	zac.executeForm(Robot);
	zac.executeForm(Robot);
	zac.executeForm(Robot);
	jim.executeForm(Robot);
}