msym_error_t orbitalPolynomial(int l, int m, double *poly){ msym_error_t ret = MSYM_SUCCESS; int pdim = ipow(3,l); if(abs(m) > l) {ret = MSYM_INVALID_ORBITALS; goto err;} switch (l) { case 0 : vlcopy(pdim, spolynomial[m+l],poly); break; case 1 : vlcopy(pdim, ppolynomial[m+l],poly); break; case 2 : vlcopy(pdim, dpolynomial[m+l],poly); break; default: { msymSetErrorDetails("Cannot handle azimithal %d",l); ret = MSYM_INVALID_ORBITALS; } } err: return ret; }
/* * Display a new line at physical line p, returning * the depth of the newly displayed line. We may decide * to expand the window on an intelligent terminal if it is * less than a full screen by deleting a line above the top of the * window before doing an insert line to keep all the good text * on the screen in which case the line may actually end up * somewhere other than line p. */ void vopen(line *tp, int p) { register int cnt; register struct vlinfo *vp, *vpc; #ifdef ADEBUG if (trace != NULL) tfixnl(), fprintf(trace, "vopen(%d, %d)\n", lineno(tp), p); #endif if (state != VISUAL) { if (vcnt) if (hold & HOLDROL) vup1(); else vclean(); /* * Forget all that we once knew. */ vcnt = vcline = 0; p = WBOT; LASTLINE = WBOT + 1; state = bastate; WTOP = basWTOP; WLINES = basWLINES; } vpc = &vlinfo[vcline]; for (vp = &vlinfo[vcnt]; vp >= vpc; vp--) vlcopy(vp[1], vp[0]); vcnt++; if (Pline == numbline) /* * Dirtying all the lines is rather inefficient * internally, but number mode is used rarely * and so its not worth optimizing. */ vdirty(vcline+1, WECHO); getline(*tp); /* * If we are opening at the top of the window, can try a window * expansion at the top. */ if (state == VISUAL && vcline == 0 && vcnt > 1 && p > ZERO) { cnt = p + vdepth() - LINE(1); if (cnt > 0) { p -= cnt; if (p < ZERO) p = ZERO; WTOP = p; WLINES = WBOT - WTOP + 1; } } vpc->vliny = p, vpc->vdepth = 0, vpc->vflags = 0; cnt = vreopen(p, lineno(tp), vcline); if (vcline + 1 == vcnt) LINE(vcnt) = LINE(vcline) + cnt; }
/* * Discard logical lines due to physical wandering off the screen. */ void vscrap(void) { register int i, j; #ifdef ADEBUG if (trace) tfixnl(), fprintf(trace, "vscrap\n"), tvliny(); #endif if (splitw) return; if (vcnt && WBOT != WECHO && LINE(0) < WTOP && LINE(0) >= ZERO) { WTOP = LINE(0); WLINES = WBOT - WTOP + 1; } for (j = 0; j < vcnt; j++) if (LINE(j) >= WTOP) { if (j == 0) break; /* * Discard the first j physical lines off the top. */ vcnt -= j, vcline -= j; for (i = 0; i <= vcnt; i++) vlcopy(vlinfo[i], vlinfo[i + j]); break; } /* * Discard lines off the bottom. */ if (vcnt) { for (j = 0; j <= vcnt; j++) if (LINE(j) > WBOT || LINE(j) + DEPTH(j) - 1 > WBOT) { vcnt = j; break; } LASTLINE = LINE(vcnt-1) + DEPTH(vcnt-1); } #ifdef ADEBUG if (trace) tvliny(); #endif /* * May have no lines! */ }
/* * Workhorse for rearranging line descriptors on changes. * The idea here is that, starting with line l, cnt lines * have been replaced with newcnt lines. All of these may * be ridiculous, i.e. l may be -1000, cnt 50 and newcnt 0, * since we may be called from an undo after the screen has * moved a lot. Thus we have to be careful. * * Many boundary conditions here. */ void vreplace(int l, int cnt, int newcnt) { register int from, to, i; bool savenote = 0; #ifdef ADEBUG if (trace) { tfixnl(), fprintf(trace, "vreplace(%d, %d, %d)\n", l, cnt, newcnt); tvliny(); } #endif if (l >= vcnt) return; if (l < 0) { if (l + cnt < 0) { /* * Nothing on the screen is relevant. * Settle for redrawing from scratch (later). */ vcnt = 0; return; } /* * Normalize l to top of screen; the add is * really a subtract from cnt since l is negative. */ cnt += l; l = 0; /* * Unseen lines were affect so notify (later). */ savenote++; } /* * These shouldn't happen * but would cause great havoc. */ if (cnt < 0) cnt = 0; if (newcnt < 0) newcnt = 0; /* * Surely worthy of note if more than report * lines were changed. */ if (cnt > value(REPORT) || newcnt > value(REPORT)) savenote++; /* * Same number of lines affeted as on screen, and we * can insert and delete lines. Thus we just type * over them, since otherwise we will push them * slowly off the screen, a clear lose. */ if (cnt == newcnt || vcnt - l == newcnt && AL && DL) { if (cnt > 1 && l + cnt > vcnt) savenote++; vdirty(l, newcnt); } else { /* * Lines are going away, squish them out. */ if (cnt > 0) { /* * If non-displayed lines went away, * always notify. */ if (cnt > 1 && l + cnt > vcnt) savenote++; if (l + cnt >= vcnt) cnt = vcnt - l; else for (from = l + cnt, to = l; from <= vcnt; to++, from++) vlcopy(vlinfo[to], vlinfo[from]); vcnt -= cnt; } /* * Open up space for new lines appearing. * All new lines are piled in the same place, * and will be unpiled by vredraw/vsync, which * inserts lines in front as it unpiles. */ if (newcnt > 0) { /* * Newlines are appearing which may not show, * so notify (this is only approximately correct * when long lines are present). */ if (newcnt > 1 && l + newcnt > vcnt + 1) savenote++; /* * If there will be more lines than fit, then * just throw way the rest of the stuff on the screen. */ if (l + newcnt > WBOT && AL && DL) { vcnt = l; goto skip; } from = vcnt, to = vcnt + newcnt; i = TUBELINES - to; if (i < 0) from += i, to += i; vcnt = to; for (; from >= l; from--, to--) vlcopy(vlinfo[to], vlinfo[from]); for (from = to + 1, to = l; to < l + newcnt && to <= WBOT + 1; to++) { LINE(to) = LINE(from); DEPTH(to) = 0; FLAGS(to) = VDIRT; } } } skip: if (Pline == numbline && cnt != newcnt) /* * When lines positions are shifted, the numbers * will be wrong. */ vdirty(l, WECHO); if (!savenote) notecnt = 0; #ifdef ADEBUG if (trace) tvliny(); #endif }