void write_vm(t_arena *arena, int addr, t_conv reg, int id) { int i; i = 0; while (i < 4) { arena->arena[my_mod((addr + i), MEM_SIZE)] = reg.octet[3 - i]; arena->color[my_mod((addr + i), MEM_SIZE)] = id; i++; } }
int GetRerverseMod(int m,int n) { int r = m; for (; ; ) { int q = r; r *= m; r = my_mod(r,n); if (r == 1) { r = q; break; } } return my_mod(r,n); }
int get_val(char type, char *values, t_arena *arena, t_proc *proc) { t_conv val; char *ind_val; int addr; val.integer = 0; if (type == A_REG) { if (is_valid_reg(type, values[0])) val.integer = proc->reg[values[0] - 1]; else val.integer = 0; } if (type == A_DIR || type == A_IND) { val.integer = oct_to_int(values); if (type == A_IND) { addr = my_mod((proc->pc + (val.integer % IDX_MOD)), MEM_SIZE); ind_val = get_value_index(&addr, arena); val.integer = oct_to_int(ind_val); } } return (val.integer); }
/* List a vector of LREAL values for the given index range */ void blockWriteLREAL(FILE *output, char *label, LREAL *vector, int first, int last) { int i, k = 0; fprintf(output, "%s", label); fprintf(output, "\n"); for(i = first; i <= last; i++) { fprintf(output, " %18g", vector[i]); k++; if(my_mod(k, 4) == 0) { fprintf(output, "\n"); k = 0; } } if(my_mod(k, 4) != 0) fprintf(output, "\n"); }
/* List the current basis matrix columns over the selected row range */ void blockWriteBMAT(FILE *output, const char *label, lprec* lp, int first, int last) { int i, j, jb, k = 0; double hold; if(first < 0) first = 0; if(last < 0) last = lp->rows; fprintf(output, "%s", label); fprintf(output, "\n"); for(i = first; i <= last; i++) { for(j = 1; j <= lp->rows; j++) { jb = lp->var_basic[j]; if(jb <= lp->rows) { if(jb == i) hold = 1; else hold = 0; } else hold = get_mat(lp, i, j); if(i == 0) modifyOF1(lp, jb, &hold, 1); hold = unscaled_mat(lp, hold, i, jb); fprintf(output, " %18g", hold); k++; if(my_mod(k, 4) == 0) { fprintf(output, "\n"); k = 0; } } if(my_mod(k, 4) != 0) { fprintf(output, "\n"); k = 0; } } if(my_mod(k, 4) != 0) fprintf(output, "\n"); }
int my_pow_mod(int m,int n,int q) { int r = 1; int i; for (i = 0; i < n ; i++) { r = r * m; r = my_mod(r,q); } return r; }
static void computeEntry(Matrix::wo_accessor &N_acc, int dx, int dy, int dz, double delta_x, double delta_y, double delta_z, int exp_x, int exp_y, int exp_z) { // get distance (dx,dy,dz) in meters const double diff_x = dx * delta_x; const double diff_y = dy * delta_y; const double diff_z = dz * delta_z; // insert components const double Nxx = demag_coeff::getN<double>(0, diff_x, diff_y, diff_z, delta_x, delta_y, delta_z); const double Nxy = demag_coeff::getN<double>(1, diff_x, diff_y, diff_z, delta_x, delta_y, delta_z); const double Nxz = demag_coeff::getN<double>(2, diff_x, diff_y, diff_z, delta_x, delta_y, delta_z); const double Nyy = demag_coeff::getN<double>(4, diff_x, diff_y, diff_z, delta_x, delta_y, delta_z); const double Nyz = demag_coeff::getN<double>(5, diff_x, diff_y, diff_z, delta_x, delta_y, delta_z); const double Nzz = demag_coeff::getN<double>(8, diff_x, diff_y, diff_z, delta_x, delta_y, delta_z); // loop through all octants // (X,Y,Z): position in demag tensor matrix for given octants (qx,qy,qz) for (int qz=-1; qz<=1; qz+=2) { const int Z = my_mod(qz*dz, exp_z); if (Z == 0 && qz != 1) continue; for (int qy=-1; qy<=1; qy+=2) { const int Y = my_mod(qy*dy, exp_y); if (Y == 0 && qy != 1) continue; for (int qx=-1; qx<=1; qx+=2) { const int X = my_mod(qx*dx, exp_x); if (X == 0 && qx != 1) continue; // fill octants N_acc.at(0, X,Y,Z) += Nxx; // even in x,y,z N_acc.at(1, X,Y,Z) += qx*qy*Nxy; // odd in x,y, even in z N_acc.at(2, X,Y,Z) += qx*qz*Nxz; // odd in x,z, even in y N_acc.at(3, X,Y,Z) += Nyy; // even in x,y,z N_acc.at(4, X,Y,Z) += qy*qz*Nyz; // odd in y,z, even in x N_acc.at(5, X,Y,Z) += Nzz; // even in x,y,z } } } }
int isPrime(int a) { int b = 2; while(b*b <= a) { if (my_mod(a,b) == 0) { return 0; } ++b; } return 1; }
int aff(t_proc *proc, t_arena *arena) { char **params; int reg; params = get_params(op_tab[15].nbr_args, arena, increase_pc(proc->pc, 1)); if (!is_valid_reg(params[TYPE_P][0], params[1][0])) return (err_instr(params, op_tab[15].nbr_args)); reg = proc->reg[params[1][0] - 1]; my_printf("%c\n", my_mod(reg, 256)); free_params(params, op_tab[15].nbr_args); proc->cycle_dodo = op_tab[15].nbr_cycles; return (1); }
int sc_main(int argc, char *argv[]) { std::cout << "in sc_main\n"; // Instanciate a container module to load Python scripts gs::script::GreenScriptModule gs_module("gs_module", "simple.py"); std::cout << "added a Python interpreter\n"; mod my_mod("dumdum"); std::cout << "added a dummy C++ component\n"; sc_core::sc_start(1.0,sc_core::SC_US); sc_core::sc_stop(); std::cout << "sc_main completed simulation and exiting\n"; return 0; }
int findPrime(Prime *p,int n) { int nAddNum = 1; while (nAddNum < n) { int len = p->ne - p->ns + 1; if (p->size <= len) { int size = 2*p->size; int *pn = (int*)malloc(size*sizeof(int)); if (pn == NULL) { return 0; } memcpy(pn,p->ns,p->size*sizeof(int)); p->ns = pn; p->ne = p->ns + len - 1; p->size = size; } nAddNum = *p->ne + 1; while(nAddNum < n) { int *pPrime = p->ns; int bHaveFoundPrime = 1; for(;*pPrime * *pPrime<=nAddNum;) { if (my_mod(nAddNum,*pPrime) == 0) { bHaveFoundPrime = 0; break; } ++pPrime; } if (bHaveFoundPrime) { p->ne++; *p->ne = nAddNum; break; } ++nAddNum; } } return 1; }
int lfork(t_proc *proc, t_arena *arena) { t_conv val; int i; int j; int addr; i = increase_pc(proc->pc, 1); j = 0; while (j < 4) { val.octet[3 - j] = arena->arena[i]; i = increase_pc(i, 1); j++; } addr = my_mod((proc->pc + val.integer), MEM_SIZE); add_proc_vm(proc, addr); proc->cycle_dodo = op_tab[14].nbr_cycles; return (5); }
int zjmp(t_proc *proc, t_arena *arena) { int i; int j; t_conv conv; if (proc->carry == 0) { proc->cycle_dodo = op_tab[8].nbr_cycles; return (5); } i = increase_pc(proc->pc, 1); j = 0; while (j < 4) { conv.octet[3 - j] = arena->arena[i]; i = increase_pc(i, 1); j++; } proc->pc = my_mod((proc->pc + (conv.integer % IDX_MOD)), MEM_SIZE); proc->cycle_dodo = op_tab[8].nbr_cycles; return (0); }
/* List the current user data matrix columns over the selected row range */ void blockWriteAMAT(FILE *output, const char *label, lprec* lp, int first, int last) { int i, j, k = 0; int nzb, nze, jb; double hold; MATrec *mat = lp->matA; if(!mat_validate(mat)) return; if(first < 0) first = 0; if(last < 0) last = lp->rows; fprintf(output, "%s", label); fprintf(output, "\n"); if(first == 0) { for(j = 1; j <= lp->columns; j++) { hold = get_mat(lp, 0, j); fprintf(output, " %18g", hold); k++; if(my_mod(k, 4) == 0) { fprintf(output, "\n"); k = 0; } } if(my_mod(k, 4) != 0) { fprintf(output, "\n"); k = 0; } first++; } nze = mat->row_end[first-1]; for(i = first; i <= last; i++) { nzb = nze; nze = mat->row_end[i]; if(nzb >= nze) jb = lp->columns+1; else jb = ROW_MAT_COLNR(nzb); for(j = 1; j <= lp->columns; j++) { if(j < jb) hold = 0; else { hold = get_mat(lp, i, j); nzb++; if(nzb < nze) jb = ROW_MAT_COLNR(nzb); else jb = lp->columns+1; } fprintf(output, " %18g", hold); k++; if(my_mod(k, 4) == 0) { fprintf(output, "\n"); k = 0; } } if(my_mod(k, 4) != 0) { fprintf(output, "\n"); k = 0; } } if(my_mod(k, 4) != 0) fprintf(output, "\n"); }
Original Author: Martin Janssen, Synopsys, Inc., 2002-03-22 *****************************************************************************/ /***************************************************************************** MODIFICATION LOG - modifiers, enter your name, affiliation, date and changes you are making here. Name, Affiliation, Date: Description of Modification: *****************************************************************************/ // test of missing sc_module_name ctor parameter error #include "systemc.h" SC_MODULE( my_mod ) { my_mod() {} }; int sc_main( int, char*[] ) { my_mod m; return 0; }