- 1
- 2
Prelude> [(-1/0),1 .. 1]
[-Infinity,1.0,Infinity,Infinity]
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 51
+136
Prelude> [(-1/0),1 .. 1]
[-Infinity,1.0,Infinity,Infinity]
Целых 2 бесконечности между единицей.
+139
struct Counter{
static int k;
Counter(){ k++; }
~Counter() { k--; }
};
int Counter::k = 0;
#define LOL(x) {string s = #x; Counter c##x; cout<<s.substr(0,1+s.find('['))<<Counter::k<<"]="<<x<<'\n'; }
+53
// quick render params menu actions
if(pe->buttons()&Qt::LeftButton || pe->buttons()&Qt::RightButton){
//
if(cRenderMenuOpended){//
if((p.x()+p.y())<18){// - -
cRenderMenuOpended=!cRenderMenuOpended;
repaint();
return;
}
else if(p.x()>5 && p.y()>5 && p.x()<145 && p.y()<cRenderMenuHeight){// actions rectangle
//
//sliceModifyMode=true; // show slice plane and can be modified
//useSlicePlane=true; // build geometry with slice plane
if(cViewType==0){// 2D
if(p.x()>10 && p.y()>22 && p.x()<140 && p.y()<38){
// reset zoom
if(c2DZoom1To1){
cPanFor2DX1to1=0;
cPanFor2D=0;
cPanFor2DX=0;
cZoomFor2D=1;
if(cViewType==0 && c2DZoom1To1 && renderLimits){
auto testSizeX=cVieportXSize;
auto testSizeY=cVieportYSize;
BoundaryConditionsOfComposite *cond=NULL;
cond=AbstractContainer::getInstance()->getBoundaryCondition(0);
if(cond->isHeatFlux_multiple()){
cPanFor2D+=15;
testSizeY-=20;
}
if(cond->isHeatFlux_multiple() || cond->isHeatFlux() || cond->isHeatPower() || cond->isConvection() || cond->isInsulated() || cond->isTemperature()){
cPanFor2D+=20;
testSizeY-=25;
}
cond=AbstractContainer::getInstance()->getBoundaryCondition(3);
if(cond->isHeatFlux() || cond->isHeatPower() || cond->isConvection() || cond->isInsulated() || cond->isTemperature()){
testSizeX-=35;
cPanFor2DX1to1+=30;
}
cond=AbstractContainer::getInstance()->getBoundaryCondition(1);
if(cond->isHeatFlux() || cond->isHeatPower() || cond->isConvection() || cond->isInsulated() || cond->isTemperature()){
testSizeX-=35;
}
if(cWidth>cThikness){
cZoomFor2D=(double(testSizeX)-50.0)/(zoomed2DX(width_sub_start)-zoomed2DX(width_sub_end));
}
else{
cZoomFor2D=(double(testSizeY)-50.0)/(zoomed2DY(thickness_sub_start)-zoomed2DY(thickness_sub_end));
}
}
}
else{
cZoomFor2D=1;
cPanFor2D=0;
cPanFor2DX=0;
}
repaint();
return;
}
else if(p.x()>10 && p.y()>42 && p.x()<140 && p.y()<58){
cForbidRenderResultsOverLayers=!cForbidRenderResultsOverLayers;
repaint();
return;
}
else if(p.x()>10 && p.y()>62 && p.x()<140 && p.y()<78){
renderLimits++;
if(renderLimits>1){
renderLimits=0;
}
repaint();
return;
}
else if(p.x()>10 && p.y()>82 && p.x()<140 && p.y()<98){
SLOT_swap2DMode11AndScaled();
return;
}
else if(p.x()>106 && p.y()>92 && p.x()<122 && p.y()<118){
cResTransparency-=0.1;
if(cResTransparency<0){cResTransparency=0;}
repaint();
return;
}
else if(p.x()>124 && p.y()>92 && p.x()<140 && p.y()<118){
cResTransparency+=0.1;
if(cResTransparency>1){cResTransparency=1;}
repaint();
return;
}
}
else{//3D
if(p.x()>10 && p.y()>22 && p.x()<140 && p.y()<38){
slot_swapCoordiantes();
return;
}
else if(p.x()>10 && p.y()>42 && p.x()<140 && p.y()<58){
Магия чисел в построении GUI
+51
QVector<double*>*** ElemBoundCond = tbc->getElementsBC();
QVector<double*>* preNodalVals = tbc->getPreNodalValues();
QVector<double*>* nodalForces = tbc->getNodalForces();
long elems = grid->getElemsNumber();
long nodes = grid->getNodesNumber();
long** Elements = grid->getElems();
double** Nodes = grid->getNodes();
long* ElemMaters = grid->getElemsMaterials();
long NBW = grid->getBandWidth();
emit signal_addLineToCalculationProtocol(">>> Solve heat problem ");
long NS[4],//+numbers of 4 nodes
NCL = 1,//number or unknown values per node (1 for thermal analysis)
ni, nj, nk,//face nodes
gnN, dN;
double ESM[4][4],//+element stiffness matrix
EF[4],//+element force matrix
**C,//matrix conteins X, Y, Z coordinates, rows like |1 Xi Yi Zi|
**CA,//conteins columns like |ai bi ci di|
//*GF,//band matrix, pointers to Global Force and Global Sriffness Matrices in A
V36,//+hexa and 36 element volume
S_3,//face area div 3
hS_3, hS_6, hS_12,//h * face area div 6 and div 12
hST_3,//h * face area * T / 3
qS_3;//q * face area / 3
QVector<double*>* fcond;
MaterialsDatabase* matdb = MaterialsDatabase::getInstance();
double Kxx, Kyy, Kzz;//thermal condactivities in X, Y and Z axes
И снова фортранщина.
+57
void NestMathematica::DATABS(){
int ks1 = 0;
int ns1=0;
int ns=0;
ia=-1;
ia=ia+1;
b[ia]=-ak[0];
ia=ia+1;
b[ia]=alfa;
mud=1;
mld=1;
if(ks!=1){
ia=ia+1;
b[ia]=0.;
ks1=ks-1;
for(int i=0; i<ks1; i++){
ns1=ns;
ns=ns+1;
if(ns!=1){
ia=ia+1;
b[ia]=0.;
}
ia=ia+1;
b[ia]=ak[ns1];
ia=ia+1;
b[ia]=0.;
ia=ia+1;
b[ia]=-ak[ns];
ia=ia+1;
b[ia]=0.;
ia=ia+1;
b[ia]=h[ns1];
ia=ia+1;
b[ia]=1.;
ia=ia+1;
b[ia]=0.;
ia=ia+1;
b[ia]=-1.;
if(ns!=ks){
ia=ia+1;
b[ia]=0.;
}
}
mud=2;
mld=2;
ia=ia+1;
b[ia]=0.;
} //10
if(beta<0){
ia=ia+1;
b[ia]=h[ks-1];
ia=ia+1;
b[ia]=1.;
}else{
ia=ia+1;
b[ia]=ak[ks]+beta*h[ks];
ia=ia+1;
b[ia]=beta;
}
return;
}
Программист на фортране может программировать на любом языке... как на фортране.
+52
double cCompositeBlock::determinant4x4(double *d){ // WARNING It's not logically connected with class.
return d[3]*d[6]*d[9]*d[12] -d[2]*d[7]*d[9]*d[12]-
d[3]*d[5]*d[10]*d[12] +d[1]*d[7]*d[10]*d[12]+
d[2]*d[5]*d[11]*d[12] -d[1]*d[6]*d[11]*d[12]-
d[3]*d[6]*d[8]*d[13] +d[2]*d[7]*d[8]*d[13]+
d[3]*d[4]*d[10]*d[13] -d[0]*d[7]*d[10]*d[13]-
d[2]*d[4]*d[11]*d[13] +d[0]*d[6]*d[11]*d[13]+
d[3]*d[5]*d[8]*d[14] -d[1]*d[7]*d[8]*d[14]-
d[3]*d[4]*d[9]*d[14] +d[0]*d[7]*d[9]*d[14]+
d[1]*d[4]*d[11]*d[14] -d[0]*d[5]*d[11]*d[14]-
d[2]*d[5]*d[8]*d[15] +d[1]*d[6]*d[8]*d[15]+
d[2]*d[4]*d[9]*d[15] -d[0]*d[6]*d[9]*d[15]-
d[1]*d[4]*d[10]*d[15] +d[0]*d[5]*d[10]*d[15];
}
+63
renderer->SetBackground(.0, .0, .0); // Background color green
+57
bool Processor::check_holes(int x, int y){
int scale = 1000000;
if((x > (die_size-mem_size)/2*scale && x < (die_size-mem_size)*scale) && (y > (die_size-mem_size)/2*scale && y < (die_size-mem_size)*scale)){
return false;
}
if((x > (die_size-mem_size)*scale) && (y > (die_size-mem_size)/2*scale && y < (die_size-mem_size)*scale)){
if(((int)(x - (die_size-mem_size)*scale) % 400) > 340 && ((int)(y - (die_size-mem_size)/2*scale) % 400) > 340){
if((x - (die_size-mem_size)*scale) < 2400){
return true;
}
}
}
if((x < (die_size-mem_size)/2*scale) && (y > (die_size-mem_size)/2*scale && y < (die_size-mem_size)*scale)){
if(((int)((die_size-mem_size)/2*scale - x) % 400) > 340 && ((int)(y - (die_size-mem_size)/2*scale) % 400) > 340){
if(((die_size-mem_size)/2*scale - x) < 2400){
return true;
}
}
}
if((y > (die_size-mem_size)*scale) && (x > (die_size-mem_size)/2*scale && x < (die_size-mem_size)*scale)){
if(((int)(y - (die_size-mem_size)*scale) % 400) > 340 && ((int)(x - (die_size-mem_size)/2*scale) % 400) > 340){
if((y - (die_size-mem_size)*scale) < 2400){
return true;
}
}
}
if((y < (die_size-mem_size)/2*scale) && (x > (die_size-mem_size)/2*scale && x < (die_size-mem_size)*scale)){
if(((int)((die_size-mem_size)/2*scale - y) % 400) > 340 && ((int)(x - (die_size-mem_size)/2*scale) % 400) > 340){
if(((die_size-mem_size)/2*scale - y) < 2400){
return true;
}
}
}
return false;
}
Проверяем дырки
+62
Grid Processor::build_grid()
{
Grid res;
double top = 340+60;
double left = 0, right = 60;
Point a,b,c,d;
for(int i = 0; i < 6; ++i){
for(int j = 0; j < 13; ++j){
a = {left*1e-6, top*1e-6, 2.1e-3};
b = {right*1e-6, top*1e-6, 2.1e-3};
c = {(left-3.25)*1e-6, (top+3.25)*1e-6, 2e-3};
d = {(right+3.25)*1e-6, (top+3.25)*1e-6, 2e-3};
auto t = std::make_tuple(a,b,c,d);
res.push_back(t);
left += (340+60);
right += (340+60);
}
top += (340+60);
left = 0;
right = 60;
}
top = (int)(-mem_size*1e6)+60;
left = (int)(mem_size*1e6)+340;
right = (int)(mem_size*1e6)+400;
for(int i = 0; i < 13; ++i){
for(int j = 0; j < 6; ++j){
a = {left*1e-6, top*1e-6, 2.1e-3};
b = {right*1e-6, top*1e-6, 2.1e-3};
c = {(left-3.25)*1e-6, (top+3.25)*1e-6, 2e-3};
d = {(right+3.25)*1e-6, (top+3.25)*1e-6, 2e-3};
auto t = std::make_tuple(a,b,c,d);
res.push_back(t);
left += (340+60);
right += (340+60);
}
top += (340+60);
left = (int)(mem_size*1e6)+340;
right = (int)(mem_size*1e6)+(340+60);
}
top = (int)(-(mem_size+2.4e-3)*1e6)+60;
left = 0, right = 60;
for(int i = 0; i < 6; ++i){
for(int j = 0; j < 13; ++j){
a = {left*1e-6, top*1e-6, 2.1e-3};
b = {right*1e-6, top*1e-6, 2.1e-3};
c = {(left-3.25)*1e-6, (top+3.25)*1e-6, 2e-3};
d = {(right+3.25)*1e-6, (top+3.25)*1e-6, 2e-3};
auto t = std::make_tuple(a,b,c,d);
res.push_back(t);
left += (340+60);
right += (340+60);
}
top += (340+60);
left = 0;
right = 60;
}
top = (int)(-mem_size*1e6)+60;
left = -2400;
right = -2400+60;
for(int i = 0; i < 13; ++i){
for(int j = 0; j < 6; ++j){
a = {left*1e-6, top*1e-6, 2.1e-3};
b = {right*1e-6, top*1e-6, 2.1e-3};
c = {(left-3.25)*1e-6, (top+3.25)*1e-6, 2e-3};
d = {(right+3.25)*1e-6, (top+3.25)*1e-6, 2e-3};
auto t = std::make_tuple(a,b,c,d);
res.push_back(t);
left += (340+60);
right += (340+60);
}
top += (340+60);
left = -2400;
right = -2400+60;
}
return res;
}
Magic numbers, Voodoo numbers!
+125
'q<->5.,q<->r<0>3.,q<T>r<0>3.,q<:>r<0>3.,q<:>r<0>3.,r<0>2.' 8!:2<.2014 3 2 3 30 46.034
Еще одни даты на J.