考虑两个Matlab向量@RequestMapping("api/v1")
//get token for staff (AD user) HttpBasic auth
@PostMapping("auth/get/stafftoken")
public ResponseEntity<?> getToken() {
// some code...
HttpHeaders tokenHeaders = new HttpHeaders();
tokenHeaders.setBearerAuth(tokenAuthenticationService.getToken());
return new ResponseEntity<>(tokenHeaders, HttpStatus.OK);
}
//get JWT if code from sms == code in my CRM-system (for client) not auth - permitAll
@PostMapping("send/clienttoken")
public @ResponseStatus
ResponseEntity<?> sendVerifyCode(@RequestParam("verifycode") String verifycode) {
// some code...
HttpHeaders tokenHeaders = new HttpHeaders();
tokenHeaders.setBearerAuth(tokenAuthenticationService.getToken());
return new ResponseEntity<>(tokenHeaders, HttpStatus.OK);
}
@RequestMapping("api/v2")
@GetMapping("get/contract/{number:[0-9]{6}")
public Contract getContract(@PathVariable String number) {
return contractsService.getContract(number);
}
A=[1 2 3 4 5]
;
我希望您建议编写大小为B=[6 7 8 9 10]
的Matlab矩阵C
,其中每一行都有:
32x5
或A(1)
B(1)
或A(2)
B(2)
或A(3)
B(3)
或A(4)
B(4)
或A(5)
B(5)
不应包含相等的行。 C
来自32
,其中2^5
是5
和A
的长度。
B
我可以手动记下 C=[1 2 3 4 5; %all elements from A (1 row)
6 2 3 4 5; %one element from B (5 rows)
1 7 3 4 5;
1 2 8 4 5;
1 2 3 9 5;
1 2 3 4 10;
6 7 3 4 5; %two elements from B (10 rows)
... ;
6 7 8 4 5; %three elements from B (10 rows)
... ;
6 7 8 9 5; %four elements from B (5 rows)]
... ;
6 7 8 9 10; %all elements from B (1 row)]
,但我想知道是否有更快的构建方法。
答案 0 :(得分:1)
类似的方法作为我对your previous question的回答:
A = [1 2 3 4 5];
B = [6 7 8 9 10];
N = numel(A);
t = dec2bin(0:2^N-1)-'0';
[~, ind_sort] = sortrows([sum(t,2) -t]);
t = t(ind_sort, :);
AB = [A B];
ind_AB = t*N + (1:N); % or bsxfun(@plus, t*N, 1:N) in old Matlab versions
result = AB(ind_AB);