CByteArray::CByteArray(const std::string & csData, bool bIsHex) { if (!bIsHex) { const unsigned char *data = reinterpret_cast<const unsigned char *>(csData.c_str()); MakeArray(data, static_cast<unsigned int>(csData.length())); } else { const char *csHexData = csData.c_str(); unsigned long ulHexLen = (int) csData.size(); m_ulCapacity = ulHexLen / 2; MakeArray(NULL, 0, m_ulCapacity); if (!m_bMallocError) { unsigned char uc = 0; bool bSecondHexDigit = true; for (unsigned long i = 0; i < ulHexLen; i++) { if (IsHexDigit(csHexData[i])) { uc = 16 * uc + Hex2Byte(csHexData[i]); bSecondHexDigit = !bSecondHexDigit; if (bSecondHexDigit) m_pucData[m_ulSize++] = uc; } } } } }
void InitNodes( void ) /***************************/ // initialize the node array structures. { GrpNodes = MakeArray( sizeof( grpnode ) ); SegNodes = MakeArray( sizeof( segnode ) ); ExtNodes = MakeArray( sizeof( extnode ) ); NameNodes = MakeArray( sizeof( list_of_names * ) ); }
static void MakeArray(zval *arr, struct descrip *ans, int dim, int *index) { int i; array_init(arr); if (dim == 0) { for (i=0;i<ans->dims[dim];i++) { switch (ans->dtype) { case DTYPE_UCHAR: add_next_index_long(arr,(int)((unsigned char *)ans->ptr)[*index]); break; case DTYPE_USHORT:add_next_index_long(arr,(int)((unsigned short *)ans->ptr)[*index]); break; case DTYPE_ULONG: add_next_index_long(arr,(int)((int *)ans->ptr)[*index]); break; case DTYPE_CHAR: add_next_index_long(arr,(int)((char *)ans->ptr)[*index]); break; case DTYPE_SHORT: add_next_index_long(arr,(int)((short *)ans->ptr)[*index]); break; case DTYPE_LONG: add_next_index_long(arr,((int *)ans->ptr)[*index]); break; case DTYPE_FLOAT: add_next_index_double(arr,(double)((float *)ans->ptr)[*index]); break; case DTYPE_DOUBLE: add_next_index_double(arr,((double *)ans->ptr)[*index]); break; case DTYPE_CSTRING: { char *string = strncpy(emalloc(ans->length+1),((char *)ans->ptr) + (*index * ans->length),ans->length); string[ans->length]=0; add_next_index_string(arr,string,0); break; } } *index = *index + 1; } } else { for (i=0;i<ans->dims[dim];i++) { zval *arr2; MAKE_STD_ZVAL(arr2); MakeArray(arr2,ans,dim-1,index); add_next_index_zval(arr,arr2); } } }
//assign data to object //?! put move logic in makeArray CByteArray & CByteArray::operator = (const CByteArray &oByteArray) { if (&oByteArray != this) //only action needed if both are not the same object { if (m_pucData == NULL) MakeArray(oByteArray.GetBytes(), oByteArray.Size()); //create new array with new data if nothing exist yet else if (m_ulCapacity >= oByteArray.Size()) { m_ulSize = oByteArray.Size(); //array large enough; copy new data in existing array memcpy(m_pucData, oByteArray.GetBytes(), m_ulSize); m_bMallocError = false; } else { m_ulCapacity = oByteArray.Size(); //array too small, create new one free(m_pucData); //ip 13/08/07 if (m_ulCapacity == 0) m_ulCapacity = EXTRA_INCREMENT_LEN; m_pucData = static_cast<unsigned char *>(malloc(m_ulCapacity)); if (m_pucData == NULL) m_bMallocError = true; else { m_ulSize = m_ulCapacity; memcpy(m_pucData, oByteArray.GetBytes(), m_ulSize); m_bMallocError = false; } } } return *this; }
void ItemContainerWidgetsPage::OnButtonTestItemContainer(wxCommandEvent&) { m_container = GetContainer(); wxASSERT_MSG(m_container, wxT("Widget must have a test widget")); wxLogMessage(wxT("wxItemContainer test for %s, %s:"), GetWidget()->GetClassInfo()->GetClassName(), (m_container->IsSorted() ? "Sorted" : "Unsorted")); const wxArrayString expected_result = m_container->IsSorted() ? MakeArray(m_itemsSorted) : m_items; StartTest(wxT("Append one item")); wxString item = m_items[0]; m_container->Append(item); EndTest(wxArrayString(1, &item)); StartTest(wxT("Append some items")); m_container->Append(m_items); EndTest(expected_result); StartTest(wxT("Append some items with data objects")); wxClientData **objects = new wxClientData *[m_items.GetCount()]; unsigned i; for ( i = 0; i < m_items.GetCount(); ++i ) objects[i] = CreateClientData(i); m_container->Append(m_items, objects); EndTest(expected_result); delete[] objects; StartTest(wxT("Append some items with data")); void **data = new void *[m_items.GetCount()]; for ( i = 0; i < m_items.GetCount(); ++i ) data[i] = wxUIntToPtr(i); m_container->Append(m_items, data); EndTest(expected_result); delete[] data; StartTest(wxT("Append some items with data, one by one")); for ( i = 0; i < m_items.GetCount(); ++i ) m_container->Append(m_items[i], wxUIntToPtr(i)); EndTest(expected_result); StartTest(wxT("Append some items with data objects, one by one")); for ( i = 0; i < m_items.GetCount(); ++i ) m_container->Append(m_items[i], CreateClientData(i)); EndTest(expected_result); if ( !m_container->IsSorted() ) { StartTest(wxT("Insert in reverse order with data, one by one")); for ( unsigned i = m_items.GetCount(); i; --i ) m_container->Insert(m_items[i - 1], 0, wxUIntToPtr(i - 1)); EndTest(expected_result); } }
int main() { //Some variables //Seed the random number generator (do only once!) srand(time(NULL)); int * p = 0; //Pointer to DMA'd int p = (int *) malloc(sizeof(int)); if(!p) { printf ("Memory Allocation Error. Your computer sucks."); return -1; } //If I got here, I got memory *p = 42; printf("The answer to life, the universe and everything is %d\n",*p); //Give my memory back if (p) free(p); p = 0; //You can reuse pointers if you're cool (and careful!) //A pointer to int can point to an int, or an array of ints p = MakeArray(ARRAYSIZE); printf("Uninitialized array:\n"); PrintArray(p,ARRAYSIZE); InitializeArray(p,ARRAYSIZE); printf("Initialized array:\n"); PrintArray(p,ARRAYSIZE); //Put away your toys! if (p) free(p); //Free don't care how big it is. p = 0; return 0; }
void XSPlotter() { double Emin, Emax, *E; long nuc, mat, rea, ne, n, i, ptr, rea1, ncol; char tmpstr[MAX_STR]; FILE *fp; unsigned long seed; /* Check if plot is defined */ if ((long)RDB[DATA_XSPLOT_NE] < 1) return; /* Check mpi task */ if (mpiid > 0) return; /* Init random number sequence */ seed = ReInitRNG(0); SEED[0] = seed; /* Set filename */ sprintf(tmpstr, "%s_xs%ld.m", GetText(DATA_PTR_INPUT_FNAME), (long)RDB[DATA_BURN_STEP]); fprintf(out, "Creating XS plot file \"%s\"...\n", tmpstr); /* Open file for writing */ if ((fp = fopen(tmpstr, "w")) == NULL) Die(FUNCTION_NAME, "Unable to open file for writing"); /* Remember collision count */ ptr = (long)RDB[DATA_PTR_COLLISION_COUNT]; ncol = GetPrivateData(ptr, 0); /***************************************************************************/ /***** Generate energy grid ************************************************/ /* Boundaries and grid size */ if (RDB[DATA_XSPLOT_EMIN] > 0.0) Emin = RDB[DATA_XSPLOT_EMIN]; else Emin = RDB[DATA_NEUTRON_EMIN]; if (RDB[DATA_XSPLOT_EMAX] > 0.0) Emax = RDB[DATA_XSPLOT_EMAX]; else Emax = RDB[DATA_NEUTRON_EMAX]; ne = (long)RDB[DATA_XSPLOT_NE]; /* Generate array */ E = MakeArray(Emin, Emax, ne, 2); /* Print array */ fprintf(fp, "E = [\n"); for (n = 0; n < ne; n++) fprintf(fp, "%1.5E\n", E[n]); fprintf(fp, "];\n\n"); /***************************************************************************/ /***** Print microscopic cross sections ************************************/ /* Loop over nuclides */ nuc = (long)RDB[DATA_PTR_NUC0]; while(nuc > VALID_PTR) { /* Check type */ if ((long)RDB[nuc + NUCLIDE_TYPE] == NUCLIDE_TYPE_DOSIMETRY) { /* Set name */ sprintf(tmpstr, "i%s", GetText(nuc + NUCLIDE_PTR_NAME)); if ((long)RDB[nuc + NUCLIDE_TYPE] != NUCLIDE_TYPE_DECAY) tmpstr[strlen(tmpstr) - 4] = '_'; /* Print reaction mt's */ fprintf(fp, "%s_mt = [\n", tmpstr); /* Loop over reactions */ rea = (long)RDB[nuc + NUCLIDE_PTR_REA]; while (rea > VALID_PTR) { /* Print mt */ fprintf(fp, "%4ld %% %s\n", (long)RDB[rea + REACTION_MT], ReactionMT((long)RDB[rea + REACTION_MT])); /* Next */ rea = NextItem(rea); } fprintf(fp, "];\n\n"); /* Print cross sections */ fprintf(fp, "%s_xs = [\n", tmpstr); for (n = 0; n < ne; n++) { /* Loop over reactions */ rea = (long)RDB[nuc + NUCLIDE_PTR_REA]; while (rea > VALID_PTR) { /* Get cross section */ if ((long)RDB[nuc + NUCLIDE_TYPE] == NUCLIDE_TYPE_PHOTON) fprintf(fp, "%1.5E ", PhotonMicroXS(rea, E[n], 0)); else fprintf(fp, "%1.5E ", MicroXS(rea, E[n], 0)); /* 0K data */ if ((rea1 = (long)RDB[rea + REACTION_PTR_0K_DATA]) > VALID_PTR) fprintf(fp, "%1.5E ", MicroXS(rea1, E[n], 0)); /* Majorant */ if ((rea1 = (long)RDB[rea + REACTION_PTR_TMP_MAJORANT]) > VALID_PTR) fprintf(fp, "%1.5E ", MicroXS(rea1, E[n], 0)); /* Next reaction */ rea = NextItem(rea); } fprintf(fp, "\n"); } fprintf(fp, "];\n\n"); } else if (((long)RDB[nuc + NUCLIDE_TYPE] != NUCLIDE_TYPE_DECAY) || ((long)RDB[nuc + NUCLIDE_TYPE_FLAGS] & NUCLIDE_FLAG_TRANSMU_DATA)) { /* Set name */ sprintf(tmpstr, "i%s", GetText(nuc + NUCLIDE_PTR_NAME)); if ((long)RDB[nuc + NUCLIDE_TYPE] != NUCLIDE_TYPE_DECAY) tmpstr[strlen(tmpstr) - 4] = '_'; /* Print reaction mt's */ fprintf(fp, "%s_mt = [\n", tmpstr); if ((long)RDB[nuc + NUCLIDE_TYPE] == NUCLIDE_TYPE_PHOTON) fprintf(fp, "%4ld %% Total\n", (long)501); else { fprintf(fp, "%4ld %% Total\n", (long)1); if ((long)RDB[nuc + NUCLIDE_PTR_SUM_ABSXS] > VALID_PTR) fprintf(fp, "%4ld %% Sum of absorption\n", (long)101); } if ((long)RDB[nuc + NUCLIDE_PTR_HEATPRODXS] > VALID_PTR) fprintf(fp, "%4ld %% Heat production\n", (long)301); if ((long)RDB[nuc + NUCLIDE_PTR_PHOTPRODXS] > VALID_PTR) fprintf(fp, "%4ld %% Photon production\n", (long)202); /* Pointer total xs */ rea = (long)RDB[nuc + NUCLIDE_PTR_TOTXS]; CheckPointer(FUNCTION_NAME, "(rea)", DATA_ARRAY, rea); if ((long)RDB[rea + REACTION_PTR_0K_DATA] > VALID_PTR) fprintf(fp, "%4ld %% %s (0K)\n", (long)RDB[rea + REACTION_MT], ReactionMT((long)RDB[rea + REACTION_MT])); if ((long)RDB[rea + REACTION_PTR_TMP_MAJORANT] > VALID_PTR) fprintf(fp, "%4ld %% %s (temperature Majorant)\n", (long)RDB[rea + REACTION_MT], ReactionMT((long)RDB[rea + REACTION_MT])); /* Pointer to partial list */ ptr = (long)RDB[rea + REACTION_PTR_PARTIAL_LIST]; CheckPointer(FUNCTION_NAME, "(ptr)", DATA_ARRAY, ptr); /* Loop over partials */ i = 0; while ((rea = ListPtr(ptr, i++)) > VALID_PTR) { /* Pointer to reaction data */ rea = (long)RDB[rea + RLS_DATA_PTR_REA]; CheckPointer(FUNCTION_NAME, "(rea)", DATA_ARRAY, rea); /* Print mt */ fprintf(fp, "%4ld %% %s\n", (long)RDB[rea + REACTION_MT], ReactionMT((long)RDB[rea + REACTION_MT])); if ((long)RDB[rea + REACTION_PTR_0K_DATA] > VALID_PTR) fprintf(fp, "%4ld %% %s (0K)\n", (long)RDB[rea + REACTION_MT], ReactionMT((long)RDB[rea + REACTION_MT])); if ((long)RDB[rea + REACTION_PTR_TMP_MAJORANT] > VALID_PTR) fprintf(fp, "%4ld %% %s (temperature Majorant)\n", (long)RDB[rea + REACTION_MT], ReactionMT((long)RDB[rea + REACTION_MT])); } fprintf(fp, "];\n\n"); /* Print cross sections */ fprintf(fp, "%s_xs = [\n", tmpstr); for (n = 0; n < ne; n++) { /* Pointer to total xs */ rea = (long)RDB[nuc + NUCLIDE_PTR_TOTXS]; CheckPointer(FUNCTION_NAME, "(rea)", DATA_ARRAY, rea); /* Get cross section */ if ((long)RDB[nuc + NUCLIDE_TYPE] == NUCLIDE_TYPE_PHOTON) fprintf(fp, "%1.5E ", PhotonMicroXS(rea, E[n], 0)); else fprintf(fp, "%1.5E ", MicroXS(rea, E[n], 0)); /* Pointer to total absorption xs */ if ((rea1 = (long)RDB[nuc + NUCLIDE_PTR_SUM_ABSXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MicroXS(rea1, E[n], 0)); /* Heat production */ if ((long)RDB[nuc + NUCLIDE_TYPE] == NUCLIDE_TYPE_PHOTON) { ptr = (long)RDB[nuc + NUCLIDE_PTR_PHOTON_HEATPRODXS]; fprintf(fp, "%1.5E ", PhotonMicroXS(ptr, E[n], 0)); } else if ((ptr = (long)RDB[nuc + NUCLIDE_PTR_HEATPRODXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MicroXS(ptr, E[n], 0)); /* Photon production */ if ((long)RDB[nuc + NUCLIDE_TYPE] == NUCLIDE_TYPE_TRANSPORT) if ((ptr = (long)RDB[nuc + NUCLIDE_PTR_PHOTPRODXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MicroXS(ptr, E[n], 0)); /* 0K data */ if ((rea1 = (long)RDB[rea + REACTION_PTR_0K_DATA]) > VALID_PTR) fprintf(fp, "%1.5E ", MicroXS(rea1, E[n], 0)); /* Majorant */ if ((rea1 = (long)RDB[rea + REACTION_PTR_TMP_MAJORANT]) > VALID_PTR) fprintf(fp, "%1.5E ", MicroXS(rea1, E[n], 0)); /* Pointer to partial list */ ptr = (long)RDB[rea + REACTION_PTR_PARTIAL_LIST]; CheckPointer(FUNCTION_NAME, "(ptr)", DATA_ARRAY, ptr); /* Loop over partials */ i = 0; while ((rea = ListPtr(ptr, i++)) > VALID_PTR) { /* Pointer to reaction data */ rea = (long)RDB[rea + RLS_DATA_PTR_REA]; CheckPointer(FUNCTION_NAME, "(rea)", DATA_ARRAY, rea); /* Get cross section */ if ((long)RDB[nuc + NUCLIDE_TYPE] == NUCLIDE_TYPE_PHOTON) fprintf(fp, "%1.5E ", PhotonMicroXS(rea, E[n], 0)); else fprintf(fp, "%1.5E ", MicroXS(rea, E[n], 0)); /* 0K data */ if ((rea1 = (long)RDB[rea + REACTION_PTR_0K_DATA]) > VALID_PTR) fprintf(fp, "%1.5E ", MicroXS(rea1, E[n], 0)); /* Majorant */ if ((rea1 = (long)RDB[rea + REACTION_PTR_TMP_MAJORANT]) > VALID_PTR) fprintf(fp, "%1.5E ", MicroXS(rea1, E[n], 0)); } fprintf(fp, "\n"); } fprintf(fp, "];\n\n"); /* Print multi-group cross sections */ if ((long)RDB[DATA_OPTI_MG_MODE] == YES) { fprintf(fp, "%s_mg_xs = [\n", tmpstr); for (n = 0; n < ne; n++) { /* Pointer total xs */ rea = (long)RDB[nuc + NUCLIDE_PTR_TOTXS]; CheckPointer(FUNCTION_NAME, "(rea)", DATA_ARRAY, rea); /* Get cross section */ fprintf(fp, "%1.5E ", MGXS(rea, E[n], -1, 0)); fprintf(fp, "\n"); } fprintf(fp, "];\n\n"); } } /* Next nuclide */ nuc = NextItem(nuc); } /***************************************************************************/ /***** Print photon yields *************************************************/ if ((long)RDB[DATA_PHOTON_PRODUCTION] == YES) { /* Loop over nuclides */ nuc = (long)RDB[DATA_PTR_NUC0]; while(nuc > VALID_PTR) { /* Check if reactions exist */ if ((long)RDB[nuc + NUCLIDE_PTR_PHOTON_PROD] < VALID_PTR) { /* Next nuclide */ nuc = NextItem(nuc); /* Cycle loop */ continue; } /* Print mt's */ sprintf(tmpstr, "i%s", GetText(nuc + NUCLIDE_PTR_NAME)); tmpstr[strlen(tmpstr) - 4] = '_'; fprintf(fp, "%s_pprod_mt = [\n", tmpstr); /* Loop over reactions */ ptr = (long)RDB[nuc + NUCLIDE_PTR_PHOTON_PROD]; while (ptr > VALID_PTR) { fprintf(fp, "%ld\n", (long)RDB[ptr + PHOTON_PROD_MT]); ptr = NextItem(ptr); } fprintf(fp, "];\n\n"); /* Print cross sections */ sprintf(tmpstr, "i%s", GetText(nuc + NUCLIDE_PTR_NAME)); tmpstr[strlen(tmpstr) - 4] = '_'; fprintf(fp, "%s_pprod_xs = [\n", tmpstr); for (n = 0; n < ne; n++) { /* Loop over reactions */ ptr = (long)RDB[nuc + NUCLIDE_PTR_PHOTON_PROD]; while (ptr > VALID_PTR) { rea1 = (long)RDB[ptr + PHOTON_PROD_PTR_PRODXS]; CheckPointer(FUNCTION_NAME, "(rea1)", DATA_ARRAY, rea1); fprintf(fp, "%1.5E ", MicroXS(rea1, E[n], 0)); ptr = NextItem(ptr); } fprintf(fp, "\n"); } fprintf(fp, "];\n\n"); /* Next */ nuc = NextItem(nuc); } } /***************************************************************************/ /***** Print photon line spectra *******************************************/ /* Loop over nuclides */ nuc = (long)RDB[DATA_PTR_NUC0]; while(nuc > VALID_PTR) { /* Check if line spectra exists */ if ((ptr = (long)RDB[nuc + NUCLIDE_PTR_PHOTON_LINE_SPEC]) > VALID_PTR) { /* Set name */ sprintf(tmpstr, "i%s", GetText(nuc + NUCLIDE_PTR_NAME)); if ((long)RDB[nuc + NUCLIDE_TYPE] != NUCLIDE_TYPE_DECAY) tmpstr[strlen(tmpstr) - 4] = '_'; /* Print spectra */ fprintf(fp, "%s_pspec = [\n", tmpstr); while (ptr > VALID_PTR) { fprintf(fp, "%1.5E %1.5E\n", RDB[ptr + PHOTON_LINE_SPEC_E], RDB[ptr + PHOTON_LINE_SPEC_RI]); /* Next line */ ptr = NextItem(ptr); } fprintf(fp, "];\n\n"); } /* Next nuclide */ nuc = NextItem(nuc); } /***************************************************************************/ /***** Print nubar data ****************************************************/ /* Loop over nuclides */ nuc = (long)RDB[DATA_PTR_NUC0]; while(nuc > VALID_PTR) { /* Pointer to fission channel */ if ((rea = (long)RDB[nuc + NUCLIDE_PTR_FISSXS]) > VALID_PTR) { /* Set name */ sprintf(tmpstr, "i%s", GetText(nuc + NUCLIDE_PTR_NAME)); if ((long)RDB[nuc + NUCLIDE_TYPE] != NUCLIDE_TYPE_DECAY) tmpstr[strlen(tmpstr) - 4] = '_'; /* Print nubars */ fprintf(fp, "%s_nu = [\n", tmpstr); for (n = 0; n < ne; n++) { /* Prompt nubar data */ if ((ptr = (long)RDB[rea + REACTION_PTR_TNUBAR])> VALID_PTR) fprintf(fp, "%1.5f ", Nubar(ptr, E[n], 0)); /* Delayed nubar data */ if ((ptr = (long)RDB[rea + REACTION_PTR_DNUBAR])> VALID_PTR) fprintf(fp, "%1.5f ", Nubar(ptr, E[n], 0)); fprintf(fp, "\n"); } fprintf(fp, "];\n\n"); } /* Next nuclide */ nuc = NextItem(nuc); } /***************************************************************************/ /***** Print energy-dependent isomeric branching ratios ********************/ /* Tää tehtiinkin eri tavalla */ #ifdef mmmmmmmmmmmmmmmmmmmmmm /* Loop over nuclides */ nuc = (long)RDB[DATA_PTR_NUC0]; while (nuc > VALID_PTR) { /* Check pointer to branching data */ if ((long)RDB[nuc + NUCLIDE_BRA_TYPE] != BRA_TYPE_ENE) { /* Next nuclide */ nuc = NextItem(nuc); /* Cycle loop */ continue; } /* Set name */ sprintf(tmpstr, "i%s", GetText(nuc + NUCLIDE_PTR_NAME)); tmpstr[strlen(tmpstr) - 4] = '_'; /* Print data */ fprintf(fp, "%s_bra = [\n", tmpstr); for (n = 0; n < ne; n++) { /* Loop over reactions */ rea = (long)RDB[nuc + NUCLIDE_PTR_REA]; while (rea > VALID_PTR) { /* Check pointer to branching data */ if ((long)RDB[rea + REACTION_RFS] > 0) fprintf(fp, "%1.5E ", MicroXS(rea, E[n], 0)); /* Next reaction */ rea = NextItem(rea); } fprintf(fp, "\n"); } fprintf(fp, "];\n\n"); /* Next nuclide */ nuc = NextItem(nuc); } #endif /***************************************************************************/ /***** Print macroscopic cross sections ************************************/ /* Loop over materials */ mat = (long)RDB[DATA_PTR_M0]; while(mat > VALID_PTR) { /* Set name */ sprintf(tmpstr, "m%s", GetText(mat + MATERIAL_PTR_NAME)); /* Print reaction mt's */ fprintf(fp, "%s_mt = [\n", tmpstr); if ((rea = (long)RDB[mat + MATERIAL_PTR_TOTXS]) > VALID_PTR) fprintf(fp, "%4ld\n", (long)RDB[rea + REACTION_MT]); if ((rea = (long)RDB[mat + MATERIAL_PTR_ELAXS]) > VALID_PTR) fprintf(fp, "%4ld\n", (long)RDB[rea + REACTION_MT]); if ((rea = (long)RDB[mat + MATERIAL_PTR_ABSXS]) > VALID_PTR) fprintf(fp, "%4ld\n", (long)RDB[rea + REACTION_MT]); if ((rea = (long)RDB[mat + MATERIAL_PTR_FISSXS]) > VALID_PTR) fprintf(fp, "%4ld\n", (long)RDB[rea + REACTION_MT]); if ((rea = (long)RDB[mat + MATERIAL_PTR_HEATTXS]) > VALID_PTR) fprintf(fp, "%4ld\n", (long)RDB[rea + REACTION_MT]); if ((rea = (long)RDB[mat + MATERIAL_PTR_PHOTPXS]) > VALID_PTR) fprintf(fp, "%4ld\n", (long)RDB[rea + REACTION_MT]); if ((rea = (long)RDB[mat + MATERIAL_PTR_NSF]) > VALID_PTR) fprintf(fp, "%4ld\n", (long)RDB[rea + REACTION_MT]); if ((rea = (long)RDB[mat + MATERIAL_PTR_INLPXS]) > VALID_PTR) fprintf(fp, "%4ld\n", (long)RDB[rea + REACTION_MT]); if ((rea = (long)RDB[mat + MATERIAL_PTR_TOTPHOTXS]) > VALID_PTR) fprintf(fp, "%4ld\n", (long)RDB[rea + REACTION_MT]); if ((rea = (long)RDB[mat + MATERIAL_PTR_HEATPHOTXS]) > VALID_PTR) fprintf(fp, "%4ld\n", (long)RDB[rea + REACTION_MT]); if ((rea = (long)RDB[mat + MATERIAL_PTR_TMP_MAJORANTXS]) > VALID_PTR) fprintf(fp, "%4ld\n", (long)RDB[rea + REACTION_MT]); fprintf(fp, "];\n\n"); /* Print cross sections */ fprintf(fp, "%s_xs = [\n", tmpstr); for (n = 0; n < ne; n++) { /* Add to counter */ ptr = (long)RDB[DATA_PTR_COLLISION_COUNT]; AddPrivateData(ptr, 1.0, 0); if ((rea = (long)RDB[mat + MATERIAL_PTR_TOTXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MacroXS(rea, E[n],0)); if ((rea = (long)RDB[mat + MATERIAL_PTR_ELAXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MacroXS(rea, E[n],0)); if ((rea = (long)RDB[mat + MATERIAL_PTR_ABSXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MacroXS(rea, E[n],0)); if ((rea = (long)RDB[mat + MATERIAL_PTR_FISSXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MacroXS(rea, E[n],0)); if ((rea = (long)RDB[mat + MATERIAL_PTR_HEATTXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MacroXS(rea, E[n],0)); if ((rea = (long)RDB[mat + MATERIAL_PTR_PHOTPXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MacroXS(rea, E[n],0)); if ((rea = (long)RDB[mat + MATERIAL_PTR_NSF]) > VALID_PTR) fprintf(fp, "%1.5E ", MacroXS(rea, E[n],0)); if ((rea = (long)RDB[mat + MATERIAL_PTR_INLPXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MacroXS(rea, E[n],0)); if ((rea = (long)RDB[mat + MATERIAL_PTR_TOTPHOTXS]) > VALID_PTR) fprintf(fp, "%1.5E ", PhotonMacroXS(rea, E[n], 0)); if ((rea = (long)RDB[mat + MATERIAL_PTR_HEATPHOTXS]) > VALID_PTR) fprintf(fp, "%1.5E ", PhotonMacroXS(rea, E[n], 0)); if ((rea = (long)RDB[mat + MATERIAL_PTR_TMP_MAJORANTXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MacroXS(rea, E[n],0)); fprintf(fp, "\n"); } fprintf(fp, "];\n\n"); /* Next material */ mat = NextItem(mat); } /***************************************************************************/ /***** Print multi-group macroscopic xs ************************************/ /* Check mode */ if ((long)RDB[DATA_OPTI_MG_MODE] == YES) { /* Loop over materials */ mat = (long)RDB[DATA_PTR_M0]; while(mat > VALID_PTR) { /* Set name */ sprintf(tmpstr, "m%s", GetText(mat + MATERIAL_PTR_NAME)); /* Print cross sections */ fprintf(fp, "%s_mg_xs = [\n", tmpstr); for (n = 0; n < ne; n++) { if ((rea = (long)RDB[mat + MATERIAL_PTR_TOTXS]) > VALID_PTR) { if ((ptr = (long)RDB[rea + REACTION_PTR_MGXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MGXS(rea, E[n], -1, 0)); } if ((rea = (long)RDB[mat + MATERIAL_PTR_ELAXS]) > VALID_PTR) { if ((ptr = (long)RDB[rea + REACTION_PTR_MGXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MGXS(rea, E[n], -1, 0)); } if ((rea = (long)RDB[mat + MATERIAL_PTR_ABSXS]) > VALID_PTR) { if ((ptr = (long)RDB[rea + REACTION_PTR_MGXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MGXS(rea, E[n], -1, 0)); } if ((rea = (long)RDB[mat + MATERIAL_PTR_FISSXS]) > VALID_PTR) { if ((ptr = (long)RDB[rea + REACTION_PTR_MGXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MGXS(rea, E[n], -1, 0)); } if ((rea = (long)RDB[mat + MATERIAL_PTR_INLPXS]) > VALID_PTR) { if ((ptr = (long)RDB[rea + REACTION_PTR_MGXS]) > VALID_PTR) fprintf(fp, "%1.5E ", MGXS(rea, E[n], -1, 0)); } fprintf(fp, "\n"); } fprintf(fp, "];\n\n"); /* Next material */ mat = NextItem(mat); } } /***************************************************************************/ /***** Print majorant ******************************************************/ /* TODO: muuta tohon ne simulation moodit instead */ if ((rea = (long)RDB[DATA_PTR_MAJORANT]) > VALID_PTR) { fprintf(fp, "majorant_xs = [\n"); for (n = 0; n < ne; n++) fprintf(fp, "%1.5E\n", DTMajorant(PARTICLE_TYPE_NEUTRON, E[n],0)); fprintf(fp, "];\n\n"); } if ((rea = (long)RDB[DATA_PTR_PHOTON_MAJORANT]) > VALID_PTR) { fprintf(fp, "photon_majorant_xs = [\n"); for (n = 0; n < ne; n++) fprintf(fp, "%1.5E\n", DTMajorant(PARTICLE_TYPE_GAMMA, E[n],0)); fprintf(fp, "];\n\n"); } /***************************************************************************/ /* Free memory */ Mem(MEM_FREE, E); /* Close file */ fclose(fp); /* Restore collision count */ ptr = (long)RDB[DATA_PTR_COLLISION_COUNT]; PutPrivateData(ptr, ncol, 0); /* Exit */ fprintf(out, "OK.\n\n"); }
Type* Type::Read(Buffer *buf) { uint32_t kind = 0; uint32_t width = 0; uint32_t count = 0; bool sign = false; bool varargs = false; String *name = NULL; Type *target_type = NULL; TypeCSU *csu_type = NULL; Vector<Type*> argument_types; Try(ReadOpenTag(buf, TAG_Type)); while (!ReadCloseTag(buf, TAG_Type)) { switch (PeekOpenTag(buf)) { case TAG_Kind: { Try(!kind); Try(ReadTagUInt32(buf, TAG_Kind, &kind)); break; } case TAG_Width: { Try(ReadTagUInt32(buf, TAG_Width, &width)); break; } case TAG_Sign: { Try(ReadTagEmpty(buf, TAG_Sign)); sign = true; break; } case TAG_Name: { Try(!name); Try(kind == YK_CSU); name = String::ReadWithTag(buf, TAG_Name); break; } case TAG_Type: { Try(!target_type); Try(kind == YK_Pointer || kind == YK_Array || kind == YK_Function); target_type = Type::Read(buf); break; } case TAG_Count: { Try(kind == YK_Array); Try(ReadTagUInt32(buf, TAG_Count, &count)); break; } case TAG_TypeFunctionCSU: { Try(!csu_type); Try(ReadOpenTag(buf, TAG_TypeFunctionCSU)); csu_type = Type::Read(buf)->AsCSU(); Try(ReadCloseTag(buf, TAG_TypeFunctionCSU)); break; } case TAG_TypeFunctionVarArgs: { Try(kind == YK_Function); Try(ReadTagEmpty(buf, TAG_TypeFunctionVarArgs)); varargs = true; break; } case TAG_TypeFunctionArguments: { Try(kind == YK_Function); Try(argument_types.Empty()); Try(ReadOpenTag(buf, TAG_TypeFunctionArguments)); while (!ReadCloseTag(buf, TAG_TypeFunctionArguments)) { Type *ntype = Type::Read(buf); argument_types.PushBack(ntype); } break; } default: Try(false); } } switch ((TypeKind)kind) { case YK_Error: return MakeError(); case YK_Void: return MakeVoid(); case YK_Int: return MakeInt(width, sign); case YK_Float: return MakeFloat(width); case YK_Pointer: Try(target_type); return MakePointer(target_type, width); case YK_Array: Try(target_type); return MakeArray(target_type, count); case YK_CSU: Try(name); return MakeCSU(name); case YK_Function: Try(target_type); return MakeFunction(target_type, csu_type, varargs, argument_types); default: Try(false); } }
static nsresult GetDeviceAspectRatio(nsPresContext* aPresContext, const nsMediaFeature*, nsCSSValue& aResult) { return MakeArray(GetDeviceSize(aPresContext), aResult); }
//copy object into new object CByteArray::CByteArray(const CByteArray & oByteArray) { MakeArray(oByteArray.GetBytes(), oByteArray.Size()); }
//copy mem into object CByteArray::CByteArray(const unsigned char * pucData, unsigned long ulSize, unsigned long ulCapacity) { MakeArray(pucData, ulSize, ulCapacity); }