xshiftl.c 746 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <grass/gis.h>
  2. #include <grass/raster.h>
  3. #include <grass/calc.h>
  4. /****************************************************************
  5. shiftl(a,b) = a << b
  6. ****************************************************************/
  7. int f_shiftl(int argc, const int *argt, void **args)
  8. {
  9. CELL *res = args[0];
  10. CELL *arg1 = args[1];
  11. CELL *arg2 = args[2];
  12. int i;
  13. if (argc < 2)
  14. return E_ARG_LO;
  15. if (argc > 2)
  16. return E_ARG_HI;
  17. if (argt[1] != CELL_TYPE || argt[2] != CELL_TYPE)
  18. return E_ARG_TYPE;
  19. if (argt[0] != CELL_TYPE)
  20. return E_RES_TYPE;
  21. for (i = 0; i < columns; i++) {
  22. if (IS_NULL_C(&arg1[i]) || IS_NULL_C(&arg2[i]))
  23. SET_NULL_C(&res[i]);
  24. else
  25. res[i] = arg1[i] << arg2[i];
  26. }
  27. return 0;
  28. }