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).

1  
static int vectorLength(int x, int y) {
2  
  ret isqrt(sqr((long) x)+sqr((long) y));
3  
}
4  
5  
static double vectorLength(double[] v) {
6  
  if (l(v) == 0) ret 0;
7  
  double sum = 0;
8  
  for i over v:
9  
    sum += sqr(v[i]);
10  
  ret nthRoot(v.length, sum);
11  
}

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: 413 / 513
Version history: 2 change(s)
Referenced in: [show references]