Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

11
LINES

< > BotCompany Repo | #1010096 // vectorLength

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3116L/17K).

static int vectorLength(int x, int y) {
  ret isqrt(sqr((long) x)+sqr((long) y));
}

static double vectorLength(double[] v) {
  if (l(v) == 0) ret 0;
  double sum = 0;
  for i over v:
    sum += sqr(v[i]);
  ret nthRoot(v.length, sum);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1010096
Snippet name: vectorLength
Eternal ID of this version: #1010096/3
Text MD5: 6339e2d9d9f87de89e8d6d15161d65a6
Transpilation MD5: 0aaf2f03732e418c2b28bf60f3d2fdb3
Author: stefan
Category: javax / maths
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-11 11:54:15
Source code size: 247 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 332 / 409
Version history: 2 change(s)
Referenced in: [show references]